@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.
31 lines • 920 B
JavaScript
/**
* @module Collection
*/
import {} from "../../../../collection/contracts/_module-exports.js";
import { resolveInvokable, } from "../../../../utilities/_module-exports.js";
/**
* @internal
*/
export class AsyncInsertBeforeIterable {
collection;
predicateFn;
iterable;
constructor(collection, predicateFn, iterable) {
this.collection = collection;
this.predicateFn = predicateFn;
this.iterable = iterable;
}
async *[Symbol.asyncIterator]() {
let hasMatched = false, index = 0;
for await (const item of this.collection) {
if (!hasMatched &&
(await resolveInvokable(this.predicateFn)(item, index, this.collection))) {
yield* this.iterable;
hasMatched = true;
}
yield item;
index++;
}
}
}
//# sourceMappingURL=async-insert-before-iterable.js.map