array-permutations
v1.0.1
Published
Give all permutations from a given array
Readme
Array Permutations
import allPermutations frm 'Array-permutations';
for (const permutation of allPermutations(['Dog', 'Cat', 'Mouse'])) {
console.log(permutation);
}
/* output:
[ 'Dog' ]
[ 'Cat' ]
[ 'Dog', 'Cat' ]
[ 'Mouse' ]
[ 'Dog', 'Mouse' ]
[ 'Cat', 'Mouse' ]
[ 'Dog', 'Cat', 'Mouse' ]
*/
for (const permutation of allPermutations(['Dog', 'Cat', 'Mouse'], 2)) {
console.log(permutation);
}
/* output:
[ 'Dog', 'Cat' ]
[ 'Dog', 'Mouse' ]
[ 'Cat', 'Mouse' ]
*/