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.

33 lines 966 B
/** * @module Collection */ import {} from "../../../../collection/contracts/_module-exports.js"; import { resolveInvokable } from "../../../../utilities/_module-exports.js"; /** * @internal */ export class PartionIterable { collection; predicateFn; makeCollection; constructor(collection, predicateFn, makeCollection) { this.collection = collection; this.predicateFn = predicateFn; this.makeCollection = makeCollection; } *[Symbol.iterator]() { const arrayA = []; const arrayB = []; for (const [index, item] of this.collection.entries()) { if (resolveInvokable(this.predicateFn)(item, index, this.collection)) { arrayA.push(item); } else { arrayB.push(item); } } yield this.makeCollection(arrayA); yield this.makeCollection(arrayB); } } //# sourceMappingURL=partion-iterable.js.map