UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

27 lines 847 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DropWhileIterator = void 0; /** Drops/skips values in the input `iterator` while the predicate returns a truthy value. */ class DropWhileIterator { constructor(iterator, predicate) { this.iterator = iterator; this.predicate = predicate; this.dropped = false; } [Symbol.iterator]() { return this; } next(...args) { if (this.dropped) return this.iterator.next(...args); let next; do next = this.iterator.next(...args); while (!next.done && this.predicate(next.value)); this.dropped = true; return next; } } exports.DropWhileIterator = DropWhileIterator; exports.default = DropWhileIterator; //# sourceMappingURL=DropWhileIterator.js.map