Skip to content

Instantly share code, notes, and snippets.

@shuuuuun
Created December 4, 2017 07:28
Show Gist options
  • Save shuuuuun/56b06cfe438ec780cae04d978c296405 to your computer and use it in GitHub Desktop.
Save shuuuuun/56b06cfe438ec780cae04d978c296405 to your computer and use it in GitHub Desktop.
const toObj = (array) => {
// ex. ['str'] -> { str: 'str' }
const obj = {};
array.forEach(v => obj[v] = v);
return obj;
};
export default toObj([
// SAMPLE
'SAMPLE_MUTATION_INCREMENT',
'SAMPLE_MUTATION_DECREMENT',
'SAMPLE_ACTION_INCREMENT',
'SAMPLE_ACTION_DECREMENT',
'SAMPLE_ACTION_INCREMENT_IF_ODD',
'SAMPLE_ACTION_INCREMENT_ASYNC',
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment