@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
1 lines • 2.25 kB
Source Map (JSON)
{"version":3,"sources":["asynciterable/operators/startwith.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,sBAAgC,SAAQ,cAAuB;IAI1E,YAAY,MAA8B,EAAE,IAAe;QACzD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAoB;QAChD,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;YAC1B,MAAM,CAAC,CAAC;SACT;QACD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;YAC5D,MAAM,IAAI,CAAC;SACZ;IACH,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAU,GAAG,IAAe;IACnD,OAAO,SAAS,yBAAyB,CACvC,MAA8B;QAE9B,OAAO,IAAI,sBAAsB,CAAU,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC","file":"startwith.js","sourcesContent":["import { AsyncIterableX } from '../asynciterablex';\nimport { MonoTypeOperatorAsyncFunction } from '../../interfaces';\nimport { wrapWithAbort } from './withabort';\nimport { throwIfAborted } from '../../aborterror';\n\nexport class StartWithAsyncIterable<TSource> extends AsyncIterableX<TSource> {\n private _source: AsyncIterable<TSource>;\n private _args: TSource[];\n\n constructor(source: AsyncIterable<TSource>, args: TSource[]) {\n super();\n this._source = source;\n this._args = args;\n }\n\n async *[Symbol.asyncIterator](signal?: AbortSignal) {\n throwIfAborted(signal);\n for (const x of this._args) {\n yield x;\n }\n for await (const item of wrapWithAbort(this._source, signal)) {\n yield item;\n }\n }\n}\n\n/**\n * Prepend a value to an async-iterable sequence.\n *\n * @export\n * @template TSource The type of the elements in the source sequence.\n * @param {...TSource[]} args Elements to prepend to the specified sequence.\n * @returns {MonoTypeOperatorAsyncFunction<TSource>} The source sequence prepended with the specified values.\n */\nexport function startWith<TSource>(...args: TSource[]): MonoTypeOperatorAsyncFunction<TSource> {\n return function startWithOperatorFunction(\n source: AsyncIterable<TSource>\n ): AsyncIterableX<TSource> {\n return new StartWithAsyncIterable<TSource>(source, args);\n };\n}\n"]}