Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / src / internal / operators / mergeMap.ts
index 884e11271bfd40178a7c2720f3200764ef6c2710..d8858462f1fba393d3352bff54df0621e334ce8a 100644 (file)
@@ -2,12 +2,10 @@ import { Observable } from '../Observable';
 import { Operator } from '../Operator';
 import { Subscriber } from '../Subscriber';
 import { Subscription } from '../Subscription';
-import { subscribeToResult } from '../util/subscribeToResult';
-import { OuterSubscriber } from '../OuterSubscriber';
-import { InnerSubscriber } from '../InnerSubscriber';
 import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';
 import { map } from './map';
 import { from } from '../observable/from';
+import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';
 
 /* tslint:disable:max-line-length */
 export function mergeMap<T, O extends ObservableInput<any>>(project: (value: T, index: number) => O, concurrent?: number): OperatorFunction<T, ObservedValueOf<O>>;
@@ -106,7 +104,7 @@ export class MergeMapOperator<T, R> implements Operator<T, R> {
  * @ignore
  * @extends {Ignored}
  */
-export class MergeMapSubscriber<T, R> extends OuterSubscriber<T, R> {
+export class MergeMapSubscriber<T, R> extends SimpleOuterSubscriber<T, R> {
   private hasCompleted: boolean = false;
   private buffer: T[] = [];
   private active: number = 0;
@@ -132,18 +130,18 @@ export class MergeMapSubscriber<T, R> extends OuterSubscriber<T, R> {
     try {
       result = this.project(value, index);
     } catch (err) {
-      this.destination.error(err);
+      this.destination.error!(err);
       return;
     }
     this.active++;
-    this._innerSub(result, value, index);
+    this._innerSub(result);
   }
 
-  private _innerSub(ish: ObservableInput<R>, value: T, index: number): void {
-    const innerSubscriber = new InnerSubscriber(this, value, index);
+  private _innerSub(ish: ObservableInput<R>): void {
+    const innerSubscriber = new SimpleInnerSubscriber(this);
     const destination = this.destination as Subscription;
     destination.add(innerSubscriber);
-    const innerSubscription = subscribeToResult<T, R>(this, ish, undefined, undefined, innerSubscriber);
+    const innerSubscription = innerSubscribe(ish, innerSubscriber);
     // The returned subscription will usually be the subscriber that was
     // passed. However, interop subscribers will be wrapped and for
     // unsubscriptions to chain correctly, the wrapper needs to be added, too.
@@ -155,25 +153,22 @@ export class MergeMapSubscriber<T, R> extends OuterSubscriber<T, R> {
   protected _complete(): void {
     this.hasCompleted = true;
     if (this.active === 0 && this.buffer.length === 0) {
-      this.destination.complete();
+      this.destination.complete!();
     }
     this.unsubscribe();
   }
 
-  notifyNext(outerValue: T, innerValue: R,
-             outerIndex: number, innerIndex: number,
-             innerSub: InnerSubscriber<T, R>): void {
-    this.destination.next(innerValue);
+  notifyNext(innerValue: R): void {
+    this.destination.next!(innerValue);
   }
 
-  notifyComplete(innerSub: Subscription): void {
+  notifyComplete(): void {
     const buffer = this.buffer;
-    this.remove(innerSub);
     this.active--;
     if (buffer.length > 0) {
-      this._next(buffer.shift());
+      this._next(buffer.shift()!);
     } else if (this.active === 0 && this.hasCompleted) {
-      this.destination.complete();
+      this.destination.complete!();
     }
   }
 }