UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

37 lines (35 loc) 1.1 kB
import { AsyncIterableX } from '../asynciterablex.js'; import { wrapWithAbort } from './withabort.js'; import { throwIfAborted } from '../../aborterror.js'; /** @ignore */ export class StartWithAsyncIterable extends AsyncIterableX { _source; _args; constructor(source, args) { super(); this._source = source; this._args = args; } async *[Symbol.asyncIterator](signal) { throwIfAborted(signal); for (const x of this._args) { yield x; } for await (const item of wrapWithAbort(this._source, signal)) { yield item; } } } /** * Prepend a value to an async-iterable sequence. * * @template TSource The type of the elements in the source sequence. * @param {...TSource[]} args Elements to prepend to the specified sequence. * @returns The source sequence prepended with the specified values. */ export function startWith(...args) { return function startWithOperatorFunction(source) { return new StartWithAsyncIterable(source, args); }; } //# sourceMappingURL=startwith.js.map