1.0.1 • Published 1 year ago

array-permutations v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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' ] 
*/