Iterate by permutations in a list
Install
$ npm install permutation-iterator
Usage
Array
const permutationIterator = ; const it = ; itnext; // => { value: ['a', 'b', 'c'], done: false }itnext; // => { value: ['b', 'a', 'c'], done: false }itnext; // => { value: ['c', 'a', 'b'], done: false }itnext; // => { value: ['a', 'c', 'b'], done: false }itnext; // => { value: ['b', 'c', 'a'], done: false }itnext; // => { value: ['c', 'b', 'a'], done: false }itnext; // => { value: undefined, done: true }
Object
const it = ; // Same bahavior as arraysitnext; // => { value: ['a', 'b', 'c'], done: false }
License
MIT © Thibaut Vieux