permu

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i permu

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

1.97 kB

Total Files

4

Last publish

Collaborators

  • krnr