mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
13 lines
251 B
TypeScript
13 lines
251 B
TypeScript
export function invert<
|
|
T extends string | number | symbol,
|
|
D extends string | number | symbol,
|
|
>(obj: Record<T, D>): Record<D, T> {
|
|
const result = {} as Record<D, T>
|
|
|
|
for (const key in obj) {
|
|
result[obj[key]] = key
|
|
}
|
|
|
|
return result
|
|
}
|