combination-iterator
v0.1.0
Published
Iterate by combination in a list
Downloads
5
Maintainers
Readme
combination-iterator
Iterate by combination values in a list
Install
$ npm install combination-iterator
Usage
Array
const combinationIterator = require('combination-iterator');
const it = combinationIterator(['a', 'b', 'c']);
it.next(); // => { value: [ 'a', 'b' ], done: false }
it.next(); // => { value: [ 'a', 'c' ], done: false }
it.next(); // => { value: [ 'b', 'c' ], done: false }
it.next(); // => { value: undefined, done: true }
Object
const it = combinationIterator({
1: 'a',
2: 'b',
3: 'c'
});
// Same bahavior as arrays
it.next(); // => { value: [ 'a', 'b' ], done: false }
License
MIT © Thibaut Vieux