0.0.1 • Published 8 years ago

simplekeymirror v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

SimpleKeyMirror

Quickly create an object with values equal to its key names.

Similar to Facebook's keyMirror util but without the pain of having to write an object with every key value set to null;

Accepts either a list of function arguments or a first argument as an Array of strings.

Example

As function arguments:

  var ANIMALS = simpleKeyMirror('giraffe', 'lion', 'wombat');
  var myPet = ANIMALS.wombat;
  var isValidAnimal = !!ANIMALS[myPet];
  var isAgainValidAnimal = ANIMALS[myPet];

With an Array of strings as first argument:

  var ANIMALS = simpleKeyMirror(['giraffe', 'lion', 'wombat']);
  var myPet = ANIMALS.wombat;
  var isValidAnimal = !!ANIMALS[myPet];
  var isAgainValidAnimal = ANIMALS[myPet];

License

MIT © Adrian le Bas