Creates a namespaced object enum for events/actions/messages
Install with npm
$ npm i -S actionkey
const actionkey = require('actionkey')
const EVENTS = actionkey('APP', [
'QUIT'
])
// {
// QUIT: 'APP_QUIT'
// }
actionkey
just needs an array or an object of keys to mirror, the returned object will be frozen.
const ACTIONS = actionkey([
'RESET',
'APPEND',
'DELETE'
])
const ACTIONS = actionkey({
'RESET': null,
'APPEND': null,
'DELETE': null
})
actionkey
can also accept namespace to append to keys and will return an object with the relevant values mapped to the keys plus the namespace. It can accept either an array of keys or an object to map.
const ACTIONS = actionkey('ACTION', [
'RESET',
'APPEND',
'DELETE'
])
const ACTIONS = actionkey('ACTION', {
'RESET': null,
'APPEND': null,
'DELETE': null
})
$ npm install
$ npm test
Pull requests are always welcome, the project uses the standard code style. Please run npm test
to ensure all tests are passing and add tests for any new features or updates.
For bugs and feature requests, please create an issue.
MIT