Iterate by pairwise values in a list
$ npm install pairwise-iterator
const pairwiseIterator = require('pairwise-iterator');
const it = pairwiseIterator(['a', 'b', 'c']);
it.next(); // => { value: [ 'a', 'b' ], done: false }
it.next(); // => { value: [ 'b', 'c' ], done: false }
it.next(); // => { value: undefined, done: true }
const it = pairwiseIterator({
1: 'a',
2: 'b',
3: 'c'
});
it.next(); // => { value: [ 'a', 'b' ], done: false }
it.next(); // => { value: [ 'b', 'c' ], done: false }
it.next(); // => { value: undefined, done: true }
MIT © Thibaut Vieux