import { AsyncIterableX } from './asynciterablex.js'; import { throwIfAborted } from '../aborterror.js'; /** @ignore */ export class OfAsyncIterable extends AsyncIterableX { private _args: TSource[]; constructor(args: TSource[]) { super(); this._args = args; } async *[Symbol.asyncIterator](signal?: AbortSignal) { throwIfAborted(signal); for (const item of this._args) { yield item; } } } /** * Creates an async-iterable from the specified elements. * * @template TSource The type of the elements to create an async-iterable sequence. * @param {...TSource[]} args The elements to turn into an async-iterable sequence. * @returns {AsyncIterableX} The async-iterable sequence created from the elements. */ export function of( ...args: TSource ): AsyncIterableX { return new OfAsyncIterable(args); }