akeymirror

1.1.0 • Public • Published

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 }

Readme

Keywords

Package Sidebar

Install

npm i akeymirror

Weekly Downloads

2

Version

1.1.0

License

EPL-1.0

Last publish

Collaborators

  • bjorn.roberg