constant-keys
Utility function that takes an array of strings and returns an object with the array values as keys, and each value being the same as a key. Very useful for using as action or event name constants in something like React.
Example:
; const actions = ;
'actions' will now contain:
ADD_TODO: 'ADD_TODO' DELETE_TODO: 'DELETE_TODO'
Requirements
All code is ES6/2015 so you'll need to compile with someting like Babel.
Installation
npm install constant-keys
Example
This is how you might go about using this with something like react / flux:
// constants/todo-constants.js; 'ADD_TODO' 'DELETE_TODO';
// actions/todo-actions.js;; { dispatcherdispatch type: typesADD_TODO title }