1.0.5 • Published 6 years ago

object-key-mirror v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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