UNPKG

2.67 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/flatmapasync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,oBAAuC,SAAQ,cAAuB;IAM1E,YACE,MAAyE,EACzE,QAA+F;QAE/F,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,IAAI,KAAK,EAAE,MAAM,KAAK,IAA6B,IAAI,CAAC,OAAO,EAAE;YAC/D,IAAI,KAAK,EAAE,MAAM,KAAK,IAA6B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;gBACxE,MAAM,KAAK,CAAC;aACb;SACF;IACH,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAyE,EACzE,QAA+F,EAC/F,OAAa;IAEb,OAAO,IAAI,oBAAoB,CAAmB,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAChG,CAAC","file":"flatmapasync.js","sourcesContent":["import { AsyncIterableX } from '../asynciterable';\nimport { bindCallback } from '../util/bindcallback';\n\nclass FlatMapAsyncIterable<TSource, TResult> extends AsyncIterableX<TResult> {\n private _source: Iterable<TSource | PromiseLike<TSource>> | AsyncIterable<TSource>;\n private _selector: (\n value: TSource\n ) => Iterable<TResult | PromiseLike<TResult>> | AsyncIterable<TResult>;\n\n constructor(\n source: Iterable<TSource | PromiseLike<TSource>> | AsyncIterable<TSource>,\n selector: (value: TSource) => Iterable<TResult | PromiseLike<TResult>> | AsyncIterable<TResult>\n ) {\n super();\n this._source = source;\n this._selector = selector;\n }\n\n async *[Symbol.asyncIterator]() {\n for await (const outer of <AsyncIterable<TSource>> this._source) {\n for await (const inner of <AsyncIterable<TResult>> this._selector(outer)) {\n yield inner;\n }\n }\n }\n}\n\n/**\n * Projects each element of a sequence to a potentially async iterable and flattens the\n * resulting sequences into one sequence.\n * @param {Iterable<T | Promise<T>> | AsyncIterable<T>} source Source sequence\n * @param {function:(value: T): Iterable<R | Promise<R>> | AsyncIterable<R>} selector A transform function to apply to each element.\n * @param {Object} [thisArg] An optional \"this\" binding for the selector function.\n * @returns {AsyncIterable<R>} An async iterable whose elements are the result of invoking the one-to-many\n * transform function on each element of the input sequence.\n */\nexport function flatMapAsync<TSource, TResult>(\n source: Iterable<TSource | PromiseLike<TSource>> | AsyncIterable<TSource>,\n selector: (value: TSource) => Iterable<TResult | PromiseLike<TResult>> | AsyncIterable<TResult>,\n thisArg?: any\n): AsyncIterableX<TResult> {\n return new FlatMapAsyncIterable<TSource, TResult>(source, bindCallback(selector, thisArg, 1));\n}\n"]}
\No newline at end of file