Skip to content

Mirrored-object helper function available as 'reflect-keys' on NPM

Notifications You must be signed in to change notification settings

jackosx/reflectKeys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reflectkeys

Create an object with values that mirror its keys from a string of whitespace-separated keys

Usage

npm install reflectkeys

var reflectKeys  = require('reflectkeys');
var mirrorObject = reflectKeys("A B C");

// mirrorObject = { A: 'A', B: 'B', C: 'C' }

Input: "key1 key2 key3"

Output: {key1: key1, key2: key2, key: key3}

I use it instead of keyMirror for defining flux ActionTypes, eg:

// TodoActionTypes.js

import reflectKeys from 'reflectkeys';

const TodoActionTypes = reflectKeys(`TODO_ADD
                                     TODO_UPDATE
                                     TODO_DELETE`);

export default TodoActionTypes;

About

Mirrored-object helper function available as 'reflect-keys' on NPM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published