1 | /**
|
2 | Invert the key/value of an object.
|
3 |
|
4 | @example
|
5 | ```
|
6 | import invertKeyValue from 'invert-kv';
|
7 |
|
8 | invertKeyValue({foo: 'bar', '🦄': '🌈'});
|
9 | //=> {bar: 'foo', '🌈': '🦄'}
|
10 | ```
|
11 | */
|
12 | export default function invertKeyValue<
|
13 | T extends Record<PropertyKey, PropertyKey>
|
14 | >(
|
15 | object: T
|
16 | ): {[P in keyof T as T[P]]: keyof T extends number ? Exclude<keyof T, number> | string : P};
|