0.1.0 • Published 6 years ago

combination-iterator v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

combination-iterator Build Status codecov

Iterate by combination values in a list

Combination

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