mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 17:33:55 +00:00
refactor: create utility for enums
This commit is contained in:
committed by
Carlos Valente
parent
b28573455a
commit
8aad271ffe
@@ -33,3 +33,10 @@ export function withoutUndefinedValues<T extends Record<string, unknown>>(
|
||||
Object.keys(obj).forEach((key) => obj[key] === undefined && delete obj[key]);
|
||||
return obj as { [K in keyof T]: Exclude<T[K], undefined> };
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a value is part of an enum
|
||||
*/
|
||||
export function isValueOfEnum<T extends object>(enumObj: T, value: unknown): value is T[keyof T] {
|
||||
return Object.values(enumObj).includes(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user