iteragain
Version:
Javascript Iterable/Iterator/Generator-function utilities.
12 lines • 398 B
JavaScript
import toIterator from './toIterator';
export function consume(...args) {
var _a;
if (!args.length || typeof args[0] === 'number')
return it => consume(it, args[0]);
const it = toIterator(args[0]);
let n = (_a = args[1]) !== null && _a !== void 0 ? _a : Infinity;
while (n-- > 0 && !it.next().done)
;
}
export default consume;
//# sourceMappingURL=consume.js.map