Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm2015 / internal / operators / tap.js
1 import { Subscriber } from '../Subscriber';
2 import { noop } from '../util/noop';
3 import { isFunction } from '../util/isFunction';
4 export function tap(nextOrObserver, error, complete) {
5     return function tapOperatorFunction(source) {
6         return source.lift(new DoOperator(nextOrObserver, error, complete));
7     };
8 }
9 class DoOperator {
10     constructor(nextOrObserver, error, complete) {
11         this.nextOrObserver = nextOrObserver;
12         this.error = error;
13         this.complete = complete;
14     }
15     call(subscriber, source) {
16         return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
17     }
18 }
19 class TapSubscriber extends Subscriber {
20     constructor(destination, observerOrNext, error, complete) {
21         super(destination);
22         this._tapNext = noop;
23         this._tapError = noop;
24         this._tapComplete = noop;
25         this._tapError = error || noop;
26         this._tapComplete = complete || noop;
27         if (isFunction(observerOrNext)) {
28             this._context = this;
29             this._tapNext = observerOrNext;
30         }
31         else if (observerOrNext) {
32             this._context = observerOrNext;
33             this._tapNext = observerOrNext.next || noop;
34             this._tapError = observerOrNext.error || noop;
35             this._tapComplete = observerOrNext.complete || noop;
36         }
37     }
38     _next(value) {
39         try {
40             this._tapNext.call(this._context, value);
41         }
42         catch (err) {
43             this.destination.error(err);
44             return;
45         }
46         this.destination.next(value);
47     }
48     _error(err) {
49         try {
50             this._tapError.call(this._context, err);
51         }
52         catch (err) {
53             this.destination.error(err);
54             return;
55         }
56         this.destination.error(err);
57     }
58     _complete() {
59         try {
60             this._tapComplete.call(this._context);
61         }
62         catch (err) {
63             this.destination.error(err);
64             return;
65         }
66         return this.destination.complete();
67     }
68 }
69 //# sourceMappingURL=tap.js.map