aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/src/internal/operators/concatMap.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-28 17:26:46 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-28 17:43:56 -0700
commite4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 (patch)
tree06284a538a6008eca75051399e47db4e5d50301c /node_modules/rxjs/src/internal/operators/concatMap.ts
initial commit: scaffolding
Diffstat (limited to 'node_modules/rxjs/src/internal/operators/concatMap.ts')
-rw-r--r--node_modules/rxjs/src/internal/operators/concatMap.ts83
1 files changed, 83 insertions, 0 deletions
diff --git a/node_modules/rxjs/src/internal/operators/concatMap.ts b/node_modules/rxjs/src/internal/operators/concatMap.ts
new file mode 100644
index 0000000..1a6dc67
--- /dev/null
+++ b/node_modules/rxjs/src/internal/operators/concatMap.ts
@@ -0,0 +1,83 @@
+import { mergeMap } from './mergeMap';
+import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';
+import { isFunction } from '../util/isFunction';
+
+/* tslint:disable:max-line-length */
+export function concatMap<T, O extends ObservableInput<any>>(
+ project: (value: T, index: number) => O
+): OperatorFunction<T, ObservedValueOf<O>>;
+/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */
+export function concatMap<T, O extends ObservableInput<any>>(
+ project: (value: T, index: number) => O,
+ resultSelector: undefined
+): OperatorFunction<T, ObservedValueOf<O>>;
+/** @deprecated The `resultSelector` parameter will be removed in v8. Use an inner `map` instead. Details: https://rxjs.dev/deprecations/resultSelector */
+export function concatMap<T, R, O extends ObservableInput<any>>(
+ project: (value: T, index: number) => O,
+ resultSelector: (outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R
+): OperatorFunction<T, R>;
+/* tslint:enable:max-line-length */
+
+/**
+ * Projects each source value to an Observable which is merged in the output
+ * Observable, in a serialized fashion waiting for each one to complete before
+ * merging the next.
+ *
+ * <span class="informal">Maps each value to an Observable, then flattens all of
+ * these inner Observables using {@link concatAll}.</span>
+ *
+ * ![](concatMap.png)
+ *
+ * Returns an Observable that emits items based on applying a function that you
+ * supply to each item emitted by the source Observable, where that function
+ * returns an (so-called "inner") Observable. Each new inner Observable is
+ * concatenated with the previous inner Observable.
+ *
+ * __Warning:__ if source values arrive endlessly and faster than their
+ * corresponding inner Observables can complete, it will result in memory issues
+ * as inner Observables amass in an unbounded buffer waiting for their turn to
+ * be subscribed to.
+ *
+ * Note: `concatMap` is equivalent to `mergeMap` with concurrency parameter set
+ * to `1`.
+ *
+ * ## Example
+ *
+ * For each click event, tick every second from 0 to 3, with no concurrency
+ *
+ * ```ts
+ * import { fromEvent, concatMap, interval, take } from 'rxjs';
+ *
+ * const clicks = fromEvent(document, 'click');
+ * const result = clicks.pipe(
+ * concatMap(ev => interval(1000).pipe(take(4)))
+ * );
+ * result.subscribe(x => console.log(x));
+ *
+ * // Results in the following:
+ * // (results are not concurrent)
+ * // For every click on the "document" it will emit values 0 to 3 spaced
+ * // on a 1000ms interval
+ * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3
+ * ```
+ *
+ * @see {@link concat}
+ * @see {@link concatAll}
+ * @see {@link concatMapTo}
+ * @see {@link exhaustMap}
+ * @see {@link mergeMap}
+ * @see {@link switchMap}
+ *
+ * @param project A function that, when applied to an item emitted by the source
+ * Observable, returns an Observable.
+ * @return A function that returns an Observable that emits the result of
+ * applying the projection function (and the optional deprecated
+ * `resultSelector`) to each item emitted by the source Observable and taking
+ * values from each projected inner Observable sequentially.
+ */
+export function concatMap<T, R, O extends ObservableInput<any>>(
+ project: (value: T, index: number) => O,
+ resultSelector?: (outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R
+): OperatorFunction<T, ObservedValueOf<O> | R> {
+ return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage