The value returned from the iterator
If your iterator has a return type it must be the same as TIteratorValue, otherwise undefined
The type your iterator is expecting as what's passed to its next function. For generators this is the type returned after a yield.
The iterator you wish to map elements from
Only values for which this function returns true are yielded.
const set = new Set([1, 2, 3, 4, 5]);
const filtered = filterIterator(set, (item) => item % 2 === 0);
console.log(Array.from(filtered)); // logs out [2, 4]
Generated using TypeDoc
Given an IteratorArg and a filtering function it will return a new IterableIterator that when polled will eagerly pull values from iterator and pass them to filterer until filterer returns true for an item, or we reach the end of iterator; it will then yield this value itself.
NOTE: if iterator relies on values being passed to next, the returned IterableIterator will re-use the same next until a value passes the filterer. value until an item is raised that passes the filterer. This can lead to strange behaviours.