Have ideas to improve npm?Join in the discussion! »

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

    1.0.0 • Public • Published

    Permuter

    It generates all possible combinations receiving a set of possible attributes and values choosing one value per attribute at the time.

    Example input:

      const options = {
        optionA: ['A-value-1', 'A-value-2'],
        optionB: ['B-value-1', 'B-value-2', 'B-value-3'],
        optionC: ['C-value-1']
      }

    Example output (all possible combinations):

      [
         {
            "optionA": "A-value-1",
            "optionB": "B-value-1",
            "optionC": "C-value-1"
         },
         {
            "optionA": "A-value-1",
            "optionB": "B-value-2",
            "optionC": "C-value-1"
         },
         {
            "optionA": "A-value-1",
            "optionB": "B-value-3",
            "optionC": "C-value-1"
         },
         {
            "optionA": "A-value-2",
            "optionB": "B-value-1",
            "optionC": "C-value-1"
         },
         {
            "optionA": "A-value-2",
            "optionB": "B-value-2",
            "optionC": "C-value-1"
         },
         {
            "optionA": "A-value-2",
            "optionB": "B-value-3",
            "optionC": "C-value-1"
         }
      ]
    Install
    • (yarn) yarn install js-permuter
    • (npm) npm install js-permuter
    Use
      import { permute } from "js-permuter";
      const options = {
        optionA: ['A-value-1', 'A-value-2'],
        optionB: ['B-value-1', 'B-value-2', 'B-value-3'],
        optionC: ['C-value-1']
      }
      const allCombinations = permute(options);

    Install

    npm i js-permuter

    DownloadsWeekly Downloads

    3

    Version

    1.0.0

    License

    Apache-2.0

    Unpacked Size

    518 kB

    Total Files

    33

    Last publish

    Collaborators

    • avatar