1 | /**
|
2 | * Constructs an enumeration with keys equal to their value.
|
3 | *
|
4 | * For example:
|
5 | *
|
6 | * var COLORS = keyMirror({blue: null, red: null});
|
7 | * var myColor = COLORS.blue;
|
8 | * var isColorValid = !!COLORS[myColor];
|
9 | *
|
10 | * The last line could not be performed if the values of the generated enum were
|
11 | * not equal to their keys.
|
12 | *
|
13 | * Input: {key1: val1, key2: val2}
|
14 | * Output: {key1: key1, key2: key2}
|
15 | */
|
16 | declare function keyMirror<T extends {}>(obj: T): { [K in keyof T]: K };
|
17 |
|
18 | declare namespace keyMirror {}
|
19 |
|
20 | export = keyMirror;
|