1 | /**
|
2 | * Constructs an enumeration with keys equal to their value. If the value is an
|
3 | * object, the method is run recursively, including the parent key as a suffix.
|
4 | * An optional prefix can be provided that will be prepended to each value.
|
5 | *
|
6 | * For example:
|
7 | *
|
8 | * var ACTIONS = keyMirror({FOO: null, BAR: { BAZ: null, BOZ: null }}});
|
9 | * ACTIONS.BAR.BAZ = 'BAR.BAZ';
|
10 | *
|
11 | * Input: {key1: null, key2: { nested1: null, nested2: null }}}
|
12 | * Output: {key1: key1, key2: { nested1: nested1, nested2: nested2 }}}
|
13 | *
|
14 | * var CONSTANTS = keyMirror({FOO: {BAR: null}}, 'NameSpace');
|
15 | * console.log(CONSTANTS.FOO.BAR); // NameSpace.FOO.BAR
|
16 | */
|
17 | declare function keyMirrorRecursive<T>(obj: T, prefix?: string | null): T;
|
18 |
|
19 | declare namespace keyMirrorRecursive {}
|
20 |
|
21 | export = keyMirrorRecursive;
|