Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

actiontypes

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

actiontypes

Generate namespaced strings for Flux standard actions

Source
npmnpm
Version
0.1.3
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

actiontypes

A dead simple a bit opinionated utility to generate namespaced strings for Flux standard actions.

It works like this:

import actionTypes from 'actiontypes';

export const namespacedActions = actionTypes(
    'namespace', // Mandatory
    'OPEN', // At least one string must be provided
    'CLOSE',
    'CLOSE', // Skips the duplicates
    'tYPO', // Forces uppercase
    'TOGGLE',
    {
       prefix: '@@', // Optional. Prepends to all strings
       delimeter: '\\', // Optional. Separator between namespace and short form, default is `/`
    }
);

const { OPEN } = namespacedAction;

console.log(namespacedAction);

/*
{ OPEN: '@@namespace\OPEN',
  CLOSE: '@@namespace\CLOSE',
  TYPO: '@@namespace\TYPO',
  TOGGLE: '@@namespace\TOGGLE' }
*/

console.log(OPEN);

/*
'@@namespace/OPEN'
*/

// No options provided:

const simpleActions = actionTypes(
  'simple',
  'HELLO',
  'THERE'
);

console.log(simpleActions);

/*
{ HELLO: 'simple/HELLO',
  THERE: 'simple/THERE' }
*/

Keywords

flux

FAQs

Package last updated on 23 Oct 2017

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