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.08 kB
/** * @module Collection */ import {} from "../../../../collection/contracts/_module-exports.js"; import { resolveInvokable } from "../../../../utilities/_module-exports.js"; /** * @internal */ export class ChunkWhileIterable { collection; predicateFn; makeCollection; constructor(collection, predicateFn, makeCollection) { this.collection = collection; this.predicateFn = predicateFn; this.makeCollection = makeCollection; } *[Symbol.iterator]() { const array = []; for (const [index, item] of this.collection.entries()) { if (index === 0) { array.push(item); } else if (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=chunk-while-iterable.js.map