permu
v1.0.0
Published
Get all possible permutations of a given length, and a given array of attributes.
Downloads
6
Maintainers
Readme
Permu
Get all possible permutations of a given length, and a given array of attributes.
npm install permu
Example
const permu = require("permu");
const items = [1, 2, 3];
const attributes = ["red", "blue"];
const permutations = permu(items.length, attributes);
console.log(permutations);
/*
[ [ 'red', 'red', 'red' ],
[ 'red', 'red', 'blue' ],
[ 'red', 'blue', 'red' ],
[ 'red', 'blue', 'blue' ],
[ 'blue', 'red', 'red' ],
[ 'blue', 'red', 'blue' ],
[ 'blue', 'blue', 'red' ],
[ 'blue', 'blue', 'blue' ] ]
*/
License
MIT