1.1.0 • Published 8 years ago

akeymirror v1.1.0

Weekly downloads
5
License
EPL-1.0
Repository
github
Last release
8 years ago

akeymirror

like keymirror, but accepts an array instead of an object with unnecessary nulls

Create an enum like object where the keys are the same as their values based on the strings in the supplied array.

var COLORS = aKeyMirror([
  'green',
  'purple'
]);
var aColor = COLORS.green;
var isColorValid = !!COLORS[aColor];

The last line could not be performed if the values of the generated enum were not equal to their keys.

Input:  ['key1',     'key2']
Output: { key1: key1, key2: key2 }