New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

action-types

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

action-types

Conveniently create action types with nested namespace support.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by16.67%
Maintainers
1
Weekly downloads
 
Created
Source

action-types

es6 js-standard-style

Conveniently create action types with multi-level namespace support.

A note about compatibility

The npm package should be used in an ES6 environment. Even though the published code has ES5 syntax it uses some ES6 features, so you have to make sure to use ES5 and ES6 polyfills if you are in an ancient environment.

Install

npm install action-types

Usage

import { ActionType, createActionTypes } from './action-types'

createActionTypes({
  START_APP: ActionType,
  user: {
    ADD: ActionType,
    REMOVE: ActionType,
    current: {
      SET: ActionType,
      CHANGE: ActionType
    }
  }
})

// results in:

{
  START_APP: 'START_APP',
  user: {
    ADD: 'user.ADD',
    REMOVE: 'user.REMOVE',
    CHANGE: 'user.CHANGE',
    current: {
      SET: 'user.current.SET',
      CHANGE: 'user.current.CHANGE'
    }
  }
}

With initial namespace

import { ActionType, createActionTypes } from './action-types'

createActionTypes({
  ADD: ActionType,
  REMOVE: ActionType
}, {
  namespace: 'user'
})

// results in:

{
  ADD: 'user.ADD',
  REMOVE: 'user.REMOVE'
}

With custom namespace separator

import { ActionType, createActionTypes } from './action-types'

createActionTypes({
  user: {
    ADD: ActionType,
    REMOVE: ActionType
  }
}, {
  separator: '::'
})

// results in:

{
  ADD: 'user::ADD',
  REMOVE: 'user::REMOVE'
}

Test

npm test

License

MIT

Keywords

FAQs

Package last updated on 12 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc