UNPKG

676 BJavaScriptView Raw
1import { IterableX } from './iterablex';
2class AnonymousIterable extends IterableX {
3 constructor(fn) {
4 super();
5 this._fn = fn;
6 }
7 [Symbol.iterator]() {
8 return this._fn();
9 }
10}
11/**
12 * Creates a new iterable using the specified function implementing the members of AsyncIterable
13 *
14 * @export
15 * @template T The type of the elements returned by the iterable sequence.
16 * @param {(() => Iterator<T>)} fn The function that creates the [Symbol.iterator]() method
17 * @returns {IterableX<T>} A new iterable instance.
18 */
19export function create(getIterator) {
20 return new AnonymousIterable(getIterator);
21}
22
23//# sourceMappingURL=create.mjs.map