This commit is contained in:
Stephen Zhou
2026-02-06 17:17:22 +08:00
parent dfa0062e97
commit b58ed66d1c
2 changed files with 61 additions and 50 deletions

7
web/utils/object.ts Normal file
View File

@ -0,0 +1,7 @@
export function ObjectFromEntries<const T extends ReadonlyArray<readonly [PropertyKey, unknown]>>(entries: T): { [K in T[number]as K[0]]: K[1] } {
return Object.fromEntries(entries) as { [K in T[number]as K[0]]: K[1] }
}
export function ObjectKeys<const T extends Record<string, unknown>>(obj: T): (keyof T)[] {
return Object.keys(obj) as (keyof T)[]
}