iteragain
Version:
Javascript Iterable/Iterator/Generator-function utilities.
28 lines • 1.05 kB
JavaScript
/** Maps the input iterator to a new value of type `R` and filters out any values that are nullish. */
var FilterMapIterator = /** @class */ (function () {
function FilterMapIterator(iterator, iteratee) {
this.iterator = iterator;
this.iteratee = iteratee;
}
FilterMapIterator.prototype[Symbol.iterator] = function () {
return this;
};
FilterMapIterator.prototype.next = function () {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var next = (_a = this.iterator).next.apply(_a, args);
if (next.done)
return { value: undefined, done: true };
var value = this.iteratee(next.value);
if (value === null || value === undefined)
return this.next.apply(this, args);
return { value: value, done: false };
};
return FilterMapIterator;
}());
export { FilterMapIterator };
export default FilterMapIterator;
//# sourceMappingURL=FilterMapIterator.js.map