mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Add variantOf utility function for enums
This commit is contained in:
parent
352461f410
commit
84488b3e63
1 changed files with 6 additions and 1 deletions
|
@ -15,5 +15,10 @@ export function isNullish(value: any) {
|
|||
return (value === null || value === undefined);
|
||||
}
|
||||
|
||||
export function variantOf(enumValue: any) {
|
||||
if (typeof enumValue === 'string') return enumValue;
|
||||
else return Object.entries(enumValue)[0][0];
|
||||
}
|
||||
|
||||
export type Index = string | number | symbol;
|
||||
export type MaybeIndex = Index | null;
|
||||
export type MaybeIndex = Index | null;
|
||||
|
|
Loading…
Add table
Reference in a new issue