@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.
26 lines • 709 B
JavaScript
/**
* @module Collection
*/
import {} from "../../../../collection/contracts/_module-exports.js";
import { resolveInvokable } from "../../../../utilities/_module-exports.js";
/**
* @internal
*/
export class AsyncWhenIterable {
collection;
condition;
callback;
constructor(collection, condition, callback) {
this.collection = collection;
this.condition = condition;
this.callback = callback;
}
async *[Symbol.asyncIterator]() {
if (await this.condition()) {
yield* await resolveInvokable(this.callback)(this.collection);
return;
}
yield* this.collection;
}
}
//# sourceMappingURL=async-when-iterable.js.map