1.0.0 • Published 6 years ago
js-permuter v1.0.0
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);
1.0.0
6 years ago