tokeys

Given an array, create an object with matching keys and values.

  • tokeys

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
tokeys
1.1.08 years ago9 years agoMinified + gzip package size for tokeys in KB

Readme

Tokeys
Take an array of strings and turn it into an object with matching keys/values. This is used mostly for Flux constants.
var Constants = Tokeys([
    'CREATE_ITEM',
    'UPDATE_ITEM',
    'DELETE_ITEM'
]);
Creates:
{ 
    CREATE_ITEM: 'CREATE_ITEM', 
    UPDATE_ITEM: 'UPDATE_ITEM', 
    DELETE_ITEM: 'DELETE_ITEM' 
}
Which can be used like Constants.CREATE_ITEM when passing in constants to a Flux action, for example.