The JavaScript guru's KeyMirror-alternative. Functionally create constant hashes from any JavaScript object with greater performance.
npm install keykey


``javascript
> require('keykey')( 'FOO', 'BAR', 'BAZ' )
{
FOO: 'FOO',
BAR: 'BAR',
BAZ: 'BAZ'
}
`
KeyKey is a micro utility module which provides a consistent way to declare constants. KeyKey achieves a very simple task, but it tries to do so in a way that will encourage innovative use. KeyKey offers functional programming capabilities by allowing keys to be passed individually or via an array. KeyKey makes constants not just from strings, but also from any JavaScript object. It caches the resulting key mirrors, making subsequent calls faster. And this cache is accessible if needed, which could provide an interesting look into constants across your application. Check out the performance test in /test.
Plus, hey—no unnecessary nulls.
Quick Start
$3
`javascript
const keykey = require('keykey')// Arrays of keys
keykey(['foo','bar','baz']) // result -> {foo:'foo',bar:'bar',baz:'baz'}
// Individual keys
keykey('foo',true,'baz') // bools, if not in the final position, are treated as keys
`
$3
`javascript
keykey(['foo','bar','baz'], false) // no get/set
keykey('foo','bar','baz', false) // bools in the final position are treated as a cache switch
`$3
`javascript
keykey.reset() // or
keykey.resetCache()
``