1.0.1 • Published 8 years ago

actionkey v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

actionkey

Creates a namespaced object enum for events/actions/messages

Build Status npm version Dependency Status js-standard-style

Install

Install with npm

$ npm i -S actionkey

Example

const actionkey = require('actionkey')

const EVENTS = actionkey('APP', [
  'QUIT'
])

// {
//   QUIT: 'APP_QUIT'
// }

Usage

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
})

Running tests

$ npm install
$ npm test

Contributing

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.

License

MIT