UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

36 lines 1.11 kB
/** * @module Collection */ import {} from "../../../../collection/contracts/_module-exports.js"; import { resolveInvokable, } from "../../../../utilities/_module-exports.js"; /** * @internal */ export class AsyncChunkWhileIterable { collection; predicateFn; makeCollection; constructor(collection, predicateFn, makeCollection) { this.collection = collection; this.predicateFn = predicateFn; this.makeCollection = makeCollection; } async *[Symbol.asyncIterator]() { const array = []; for await (const [index, item] of this.collection.entries()) { if (index === 0) { array.push(item); } else if (await resolveInvokable(this.predicateFn)(item, index, this.makeCollection(array))) { array.push(item); } else { yield this.makeCollection(array); array.length = 0; array.push(item); } } yield this.makeCollection(array); } } //# sourceMappingURL=async-chunk-while-iterable.js.map