Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / src / internal / operators / race.ts
1 import { Observable } from '../Observable';
2 import { isArray } from '../util/isArray';
3 import { MonoTypeOperatorFunction, OperatorFunction } from '../types';
4 import { race as raceStatic } from '../observable/race';
5
6 /* tslint:disable:max-line-length */
7 /** @deprecated Deprecated in favor of static race. */
8 export function race<T>(observables: Array<Observable<T>>): MonoTypeOperatorFunction<T>;
9 /** @deprecated Deprecated in favor of static race. */
10 export function race<T, R>(observables: Array<Observable<T>>): OperatorFunction<T, R>;
11 /** @deprecated Deprecated in favor of static race. */
12 export function race<T>(...observables: Array<Observable<T> | Array<Observable<T>>>): MonoTypeOperatorFunction<T>;
13 /** @deprecated Deprecated in favor of static race. */
14 export function race<T, R>(...observables: Array<Observable<any> | Array<Observable<any>>>): OperatorFunction<T, R>;
15 /* tslint:enable:max-line-length */
16
17 /**
18  * Returns an Observable that mirrors the first source Observable to emit a next,
19  * error or complete notification from the combination of this Observable and supplied Observables.
20  * @param {...Observables} ...observables Sources used to race for which Observable emits first.
21  * @return {Observable} An Observable that mirrors the output of the first Observable to emit an item.
22  * @method race
23  * @owner Observable
24  * @deprecated Deprecated in favor of static {@link race}.
25  */
26 export function race<T>(...observables: (Observable<T> | Observable<T>[])[]): MonoTypeOperatorFunction<T> {
27   return function raceOperatorFunction(source: Observable<T>) {
28     // if the only argument is an array, it was most likely called with
29     // `pair([obs1, obs2, ...])`
30     if (observables.length === 1 && isArray(observables[0])) {
31       observables = observables[0] as Observable<T>[];
32     }
33
34     return source.lift.call(raceStatic(source, ...(observables as Observable<T>[])));
35   };
36 }