UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

22 lines 605 B
/** * An iterator that filters the values from the input Iterator<T>, to only those that return a truthy value in the * `predicate`. */ export class FilterIterator { constructor(iterator, predicate) { this.iterator = iterator; this.predicate = predicate; } [Symbol.iterator]() { return this; } next(...args) { let result; do result = this.iterator.next(...args); while (!result.done && !this.predicate(result.value)); return result; } } export default FilterIterator; //# sourceMappingURL=FilterIterator.js.map