UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

1 lines 3.16 kB
{"version":3,"sources":["asynciterable/operators/tap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,OAAO,gBAA0B,SAAQ,cAAuB;IAIpE,YAAY,MAA8B,EAAE,QAAuC;QACjF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,EAAE;YACR,IAAI,IAAI,CAAC;YACT,IAAI;gBACF,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;aACxB;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;oBACxB,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;iBAC/B;gBACD,MAAM,CAAC,CAAC;aACT;YAED,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;oBAC3B,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;iBACjC;gBACD,MAAM;aACP;YAED,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBACvB,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACvC;YACD,MAAM,IAAI,CAAC,KAAK,CAAC;SAClB;IACH,CAAC;CACF;AAYD,MAAM,UAAU,GAAG,CACjB,cAAiF,EACjF,KAAkC,EAClC,QAA6B;IAE7B,OAAO,SAAS,mBAAmB,CAAC,MAA8B;QAChE,OAAO,IAAI,gBAAgB,CAAU,MAAM,EAAE,UAAU,CAAC,cAAc,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5F,CAAC,CAAC;AACJ,CAAC","file":"tap.js","sourcesContent":["import { AsyncIterableX } from '../asynciterablex';\nimport { PartialAsyncObserver } from '../../observer';\nimport { MonoTypeOperatorAsyncFunction } from '../../interfaces';\nimport { toObserver } from '../../util/toobserver';\n\nexport class TapAsyncIterable<TSource> extends AsyncIterableX<TSource> {\n private _source: AsyncIterable<TSource>;\n private _observer: PartialAsyncObserver<TSource>;\n\n constructor(source: AsyncIterable<TSource>, observer: PartialAsyncObserver<TSource>) {\n super();\n this._source = source;\n this._observer = observer;\n }\n\n async *[Symbol.asyncIterator]() {\n const it = this._source[Symbol.asyncIterator]();\n while (1) {\n let next;\n try {\n next = await it.next();\n } catch (e) {\n if (this._observer.error) {\n await this._observer.error(e);\n }\n throw e;\n }\n\n if (next.done) {\n if (this._observer.complete) {\n await this._observer.complete();\n }\n break;\n }\n\n if (this._observer.next) {\n await this._observer.next(next.value);\n }\n yield next.value;\n }\n }\n}\n\nexport function tap<TSource>(\n observer: PartialAsyncObserver<TSource>\n): MonoTypeOperatorAsyncFunction<TSource>;\n\nexport function tap<TSource>(\n next?: ((value: TSource) => any) | null,\n error?: ((err: any) => any) | null,\n complete?: (() => any) | null\n): MonoTypeOperatorAsyncFunction<TSource>;\n\nexport function tap<TSource>(\n observerOrNext?: PartialAsyncObserver<TSource> | ((value: TSource) => any) | null,\n error?: ((err: any) => any) | null,\n complete?: (() => any) | null\n): MonoTypeOperatorAsyncFunction<TSource> {\n return function tapOperatorFunction(source: AsyncIterable<TSource>): AsyncIterableX<TSource> {\n return new TapAsyncIterable<TSource>(source, toObserver(observerOrNext, error, complete));\n };\n}\n"]}