npm.io
1.0.0 • Published 8 years ago

js-permuter

Licence
Apache-2.0
Version
1.0.0
Deps
0
Size
506 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

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);

Keywords