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

latest
Source
npmnpm
Version
0.3.2
Version published
Weekly downloads
50
194.12%
Maintainers
1
Weekly downloads
 
Created
Source

actiontypes

A simple utility to generate namespaced strings for Flux standard actions.

Usage

actionTypes(namespace, type1, [type2, ...] [, options])

actionTypes(namespace, typesArray, [, options])

Basic

import actionTypes from "actiontypes";

const actions = actionTypes("namespace", "HELLO", "THERE");

You’ll got:

console.log(actions);
{
  HELLO: "namespace/HELLO",
  THERE: "namespace/THERE"
}

More:

const actions = actionTypes(
  "namespace", // Mandatory
  "OPEN", // At least one string must be provided
  "CLOSE",
  "close", // Skips duplicates
  "tYPO", // Forces uppercase
);
console.log(actions);
{
  OPEN: "namespace/OPEN",
  CLOSE: "namespace/CLOSE",
  TYPO: "namespace/TYPO"
}

Array of types

Also an array of types strings as a second argument can be passed:

const actions = actionTypes("simple", ["HELLO", "THERE"]);

Configuration

import actionTypes from "actiontypes";

const actions = actionTypes("namespace", "INIT", {
    prefix: "@@", // Optional. Prepends to all strings. Default is `""`, an empty string.
    delimeter: "--", // Optional. Separator between namespace and short form. Default is `/`, a slash.
  }
);

And you’ll got:

console.log(actions);
{
  INIT: "@@namespace--INIT"
}

Keywords

flux

FAQs

Package last updated on 18 Jan 2018

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