Add variantOf utility function for enums

This commit is contained in:
adroslice 2024-07-30 16:29:10 +02:00
parent 352461f410
commit 84488b3e63

View file

@ -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;