@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 • 1 kB
JavaScript
/**
* @module Collection
*/
import {} from "../../../../collection/contracts/_module-exports.js";
import { resolveInvokable, } from "../../../../utilities/_module-exports.js";
/**
* @internal
*/
export class AsyncPartionIterable {
collection;
predicateFn;
makeCollection;
constructor(collection, predicateFn, makeCollection) {
this.collection = collection;
this.predicateFn = predicateFn;
this.makeCollection = makeCollection;
}
async *[Symbol.asyncIterator]() {
const arrayA = [];
const arrayB = [];
for await (const [index, item] of this.collection.entries()) {
if (await resolveInvokable(this.predicateFn)(item, index, this.collection)) {
arrayA.push(item);
}
else {
arrayB.push(item);
}
}
yield this.makeCollection(arrayA);
yield this.makeCollection(arrayB);
}
}
//# sourceMappingURL=async-partion-iterable.js.map