UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

21 lines 719 B
/** Maps the input iterator to a new value of type `R` and filters out any values that are nullish. */ export class FilterMapIterator { constructor(iterator, iteratee) { this.iterator = iterator; this.iteratee = iteratee; } [Symbol.iterator]() { return this; } next(...args) { const next = this.iterator.next(...args); if (next.done) return { value: undefined, done: true }; const value = this.iteratee(next.value); if (value === null || value === undefined) return this.next(...args); return { value: value, done: false }; } } export default FilterMapIterator; //# sourceMappingURL=FilterMapIterator.js.map