mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
12 lines
286 B
TypeScript
12 lines
286 B
TypeScript
export function createEnumMap<T extends Record<string, string | number>>(
|
|
EnumObject: T
|
|
) {
|
|
return Object.entries(EnumObject).reduce(
|
|
(acc, [key, value]) => {
|
|
acc[value as T[keyof T]] = key as keyof T;
|
|
return acc;
|
|
},
|
|
{} as Record<T[keyof T], keyof T>
|
|
);
|
|
}
|