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.

31 lines 956 B
/** * @module Collection */ import {} from "../../../../collection/contracts/_module.js"; import { resolveAsyncIterableValue, resolveInvokable, } from "../../../../utilities/_module.js"; /** * @internal */ export class AsyncInsertAfterIterable { 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) { yield item; if (!hasMatched && (await resolveInvokable(this.predicateFn)(item, index, this.collection))) { yield* resolveAsyncIterableValue(this.iterable); hasMatched = true; } index++; } } } //# sourceMappingURL=async-insert-after-iterable.js.map