Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / src / internal / operators / expand.ts
index b686d615733013db80d5367788ea986b7450f72e..2047a780787758d53ef6be4a286393fe7e55308b 100644 (file)
@@ -2,10 +2,8 @@ import { Observable } from '../Observable';
 import { Operator } from '../Operator';
 import { Subscriber } from '../Subscriber';
 import { Subscription } from '../Subscription';
-import { OuterSubscriber } from '../OuterSubscriber';
-import { InnerSubscriber } from '../InnerSubscriber';
-import { subscribeToResult } from '../util/subscribeToResult';
 import { MonoTypeOperatorFunction, OperatorFunction, ObservableInput, SchedulerLike } from '../types';
+import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
 
 /* tslint:disable:max-line-length */
 export function expand<T, R>(project: (value: T, index: number) => ObservableInput<R>, concurrent?: number, scheduler?: SchedulerLike): OperatorFunction<T, R>;
@@ -66,7 +64,7 @@ export function expand<T>(project: (value: T, index: number) => ObservableInput<
  */
 export function expand<T, R>(project: (value: T, index: number) => ObservableInput<R>,
                              concurrent: number = Number.POSITIVE_INFINITY,
-                             scheduler: SchedulerLike = undefined): OperatorFunction<T, R> {
+                             scheduler?: SchedulerLike): OperatorFunction<T, R> {
   concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
 
   return (source: Observable<T>) => source.lift(new ExpandOperator(project, concurrent, scheduler));
@@ -75,7 +73,7 @@ export function expand<T, R>(project: (value: T, index: number) => ObservableInp
 export class ExpandOperator<T, R> implements Operator<T, R> {
   constructor(private project: (value: T, index: number) => ObservableInput<R>,
               private concurrent: number,
-              private scheduler: SchedulerLike) {
+              private scheduler?: SchedulerLike) {
   }
 
   call(subscriber: Subscriber<R>, source: any): any {
@@ -95,16 +93,16 @@ interface DispatchArg<T, R> {
  * @ignore
  * @extends {Ignored}
  */
-export class ExpandSubscriber<T, R> extends OuterSubscriber<T, R> {
+export class ExpandSubscriber<T, R> extends SimpleOuterSubscriber<T, R> {
   private index: number = 0;
   private active: number = 0;
   private hasCompleted: boolean = false;
-  private buffer: any[];
+  private buffer?: any[];
 
   constructor(destination: Subscriber<R>,
               private project: (value: T, index: number) => ObservableInput<R>,
               private concurrent: number,
-              private scheduler: SchedulerLike) {
+              private scheduler?: SchedulerLike) {
     super(destination);
     if (concurrent < Number.POSITIVE_INFINITY) {
       this.buffer = [];
@@ -126,7 +124,7 @@ export class ExpandSubscriber<T, R> extends OuterSubscriber<T, R> {
 
     const index = this.index++;
     if (this.active < this.concurrent) {
-      destination.next(value);
+      destination.next!(value);
       try {
         const { project } = this;
         const result = project(value, index);
@@ -135,46 +133,42 @@ export class ExpandSubscriber<T, R> extends OuterSubscriber<T, R> {
         } else {
           const state: DispatchArg<T, R> = { subscriber: this, result, value, index };
           const destination = this.destination as Subscription;
-          destination.add(this.scheduler.schedule<DispatchArg<T, R>>(ExpandSubscriber.dispatch, 0, state));
+          destination.add(this.scheduler.schedule<DispatchArg<T, R>>(ExpandSubscriber.dispatch as any, 0, state));
         }
       } catch (e) {
-        destination.error(e);
+        destination.error!(e);
       }
     } else {
-      this.buffer.push(value);
+      this.buffer!.push(value);
     }
   }
 
   private subscribeToProjection(result: any, value: T, index: number): void {
     this.active++;
     const destination = this.destination as Subscription;
-    destination.add(subscribeToResult<T, R>(this, result, value, index));
+    destination.add(innerSubscribe(result, new SimpleInnerSubscriber(this)));
   }
 
   protected _complete(): void {
     this.hasCompleted = true;
     if (this.hasCompleted && this.active === 0) {
-      this.destination.complete();
+      this.destination.complete!();
     }
     this.unsubscribe();
   }
 
-  notifyNext(outerValue: T, innerValue: R,
-             outerIndex: number, innerIndex: number,
-             innerSub: InnerSubscriber<T, R>): void {
+  notifyNext(innerValue: R): void {
     this._next(innerValue);
   }
 
-  notifyComplete(innerSub: Subscription): void {
+  notifyComplete(): void {
     const buffer = this.buffer;
-    const destination = this.destination as Subscription;
-    destination.remove(innerSub);
     this.active--;
     if (buffer && buffer.length > 0) {
       this._next(buffer.shift());
     }
     if (this.hasCompleted && this.active === 0) {
-      this.destination.complete();
+      this.destination.complete!();
     }
   }
 }