UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

18 lines 523 B
/** Tap into the values of an iterator. `func` does not modify values passed to it as it's return value is unused. */ export class TapIterator { constructor(iterator, func) { this.iterator = iterator; this.func = func; } [Symbol.iterator]() { return this; } next(...args) { const next = this.iterator.next(...args); if (!next.done) this.func(next.value); return next; } } export default TapIterator; //# sourceMappingURL=TapIterator.js.map