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/E,CAAC,CAAC;AACJ,CAAC","file":"flatmap.js","sourcesContent":["import { AsyncIterableX } from '../asynciterablex';\nimport { OperatorAsyncFunction } from '../../interfaces';\nimport { wrapWithAbort } from './withabort';\nimport { throwIfAborted } from '../../aborterror';\n\nexport class FlatMapAsyncIterable<TSource, TResult> extends AsyncIterableX<TResult> {\n  private _source: AsyncIterable<TSource>;\n  private _selector: (\n    value: TSource,\n    index: number,\n    signal?: AbortSignal\n  ) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;\n  private _thisArg?: any;\n\n  constructor(\n    source: AsyncIterable<TSource>,\n    selector: (\n      value: TSource,\n      index: number,\n      signal?: AbortSignal\n    ) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>,\n    thisArg?: any\n  ) {\n    super();\n    this._source = source;\n    this._selector = selector;\n    this._thisArg = thisArg;\n  }\n\n  async *[Symbol.asyncIterator](signal?: AbortSignal) {\n    throwIfAborted(signal);\n    const { _source: source, _selector: selector, _thisArg: thisArg } = this;\n    let index = 0;\n    for await (const outer of wrapWithAbort(source, signal)) {\n      const inners = await selector.call(thisArg, outer, index++, signal);\n      for await (const inner of wrapWithAbort(inners, signal)) {\n        yield inner;\n      }\n    }\n  }\n}\n\n/**\n * Projects each element of an async-iterable sequence to an async-iterable sequence and merges\n * the resulting async-iterable sequences into one async-iterable sequence.\n *\n * @export\n * @template TSource The type of the elements in the source sequence.\n * @template TResult The type of the elements in the projected inner sequences and the elements in the merged result sequence.\n * @param {((\n *     value: TSource,\n *     index: number,\n *     signal?: AbortSignal\n *   ) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>)} selector A transform function to apply to each element.\n * @param {*} [thisArg] Option this for binding to the selector.\n * @returns {OperatorAsyncFunction<TSource, TResult>} An operator that creates an async-iterable sequence whose\n * elements are the result of invoking the one-to-many transform function on each element of the input sequence.\n */\nexport function flatMap<TSource, TResult>(\n  selector: (\n    value: TSource,\n    index: number,\n    signal?: AbortSignal\n  ) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>,\n  thisArg?: any\n): OperatorAsyncFunction<TSource, TResult> {\n  return function flatMapOperatorFunction(source: AsyncIterable<TSource>): AsyncIterableX<TResult> {\n    return new FlatMapAsyncIterable<TSource, TResult>(source, selector, thisArg);\n  };\n}\n"]}