Generate all possible permutations of given elements.
npm i permutationsjs
import permutations from 'permutationsjs'
const _permutations = []
permutations(
[0,1], // the elements to permutate
6, // the size of permutations
false, // whether to avoid repetition of elements in the permutations
permutation => _permutations.push(permutation) // a callback on each permutation
)
At each step of the recursion, pick one element and map all other elements to it.