Wondering what’s next for npm?Check out our public roadmap! »

    actiontypes
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.2 • Public • Published

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

    Install

    npm i actiontypes

    DownloadsWeekly Downloads

    11

    Version

    0.3.2

    License

    MIT

    Last publish

    Collaborators

    • avatar