object-key-mirror
v1.0.5
Published
Object key mirror is a zero-dependency Node.js module that lets you easily create objects with values equal to their key names.
Readme
Object Key Mirror
Object key mirror is a zero-dependency Node.js module that lets you easily create objects with values equal to their key names.
If you're one to define constants for your action types when managing state in complex applications, you'll totally love object key mirror! In fact, it's Inspired by Facebook's keyMirror.
Installation
npm install object-key-mirror --saveUsage
import mirrorKeys from 'object-key-mirror';
const actionTypes = mirrorKeys(['LOGIN_SUCCESS', 'SIGNUP_SUCCESS', 'LOGIN_FAILURE']);
// output
{
LOGIN_SUCCESS: 'LOGIN_SUCCESS',
SIGNUP_SUCCESS: 'SIGNUP_SUCCESS',
LOGIN_FAILURE: 'LOGIN_FAILURE'
}
const names = mirrorKeys(['john smith', 'doe', 'philip', 'smith']);
// output
{
"john smith": 'john smith',
doe: 'doe',
philip: 'philip',
smith: 'smith'
}