Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm2015 / internal / operators / timeoutWith.js
1 import { async } from '../scheduler/async';
2 import { isDate } from '../util/isDate';
3 import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
4 export function timeoutWith(due, withObservable, scheduler = async) {
5     return (source) => {
6         let absoluteTimeout = isDate(due);
7         let waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
8         return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
9     };
10 }
11 class TimeoutWithOperator {
12     constructor(waitFor, absoluteTimeout, withObservable, scheduler) {
13         this.waitFor = waitFor;
14         this.absoluteTimeout = absoluteTimeout;
15         this.withObservable = withObservable;
16         this.scheduler = scheduler;
17     }
18     call(subscriber, source) {
19         return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
20     }
21 }
22 class TimeoutWithSubscriber extends SimpleOuterSubscriber {
23     constructor(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
24         super(destination);
25         this.absoluteTimeout = absoluteTimeout;
26         this.waitFor = waitFor;
27         this.withObservable = withObservable;
28         this.scheduler = scheduler;
29         this.scheduleTimeout();
30     }
31     static dispatchTimeout(subscriber) {
32         const { withObservable } = subscriber;
33         subscriber._unsubscribeAndRecycle();
34         subscriber.add(innerSubscribe(withObservable, new SimpleInnerSubscriber(subscriber)));
35     }
36     scheduleTimeout() {
37         const { action } = this;
38         if (action) {
39             this.action = action.schedule(this, this.waitFor);
40         }
41         else {
42             this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
43         }
44     }
45     _next(value) {
46         if (!this.absoluteTimeout) {
47             this.scheduleTimeout();
48         }
49         super._next(value);
50     }
51     _unsubscribe() {
52         this.action = undefined;
53         this.scheduler = null;
54         this.withObservable = null;
55     }
56 }
57 //# sourceMappingURL=timeoutWith.js.map