object-key-mirror

1.0.5 • Public • Published

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.

License: MIT Build Status npm js-standard-style

Installation

npm install object-key-mirror --save

Usage

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' 
}

LICENSE

MIT © Temi Lajumoke

/object-key-mirror/

    Package Sidebar

    Install

    npm i object-key-mirror

    Weekly Downloads

    9

    Version

    1.0.5

    License

    MIT

    Last publish

    Collaborators

    • temilaj