Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / internal / operators / audit.js
1 "use strict";
2 var __extends = (this && this.__extends) || (function () {
3     var extendStatics = function (d, b) {
4         extendStatics = Object.setPrototypeOf ||
5             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6             function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7         return extendStatics(d, b);
8     }
9     return function (d, b) {
10         extendStatics(d, b);
11         function __() { this.constructor = d; }
12         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13     };
14 })();
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var innerSubscribe_1 = require("../innerSubscribe");
17 function audit(durationSelector) {
18     return function auditOperatorFunction(source) {
19         return source.lift(new AuditOperator(durationSelector));
20     };
21 }
22 exports.audit = audit;
23 var AuditOperator = (function () {
24     function AuditOperator(durationSelector) {
25         this.durationSelector = durationSelector;
26     }
27     AuditOperator.prototype.call = function (subscriber, source) {
28         return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
29     };
30     return AuditOperator;
31 }());
32 var AuditSubscriber = (function (_super) {
33     __extends(AuditSubscriber, _super);
34     function AuditSubscriber(destination, durationSelector) {
35         var _this = _super.call(this, destination) || this;
36         _this.durationSelector = durationSelector;
37         _this.hasValue = false;
38         return _this;
39     }
40     AuditSubscriber.prototype._next = function (value) {
41         this.value = value;
42         this.hasValue = true;
43         if (!this.throttled) {
44             var duration = void 0;
45             try {
46                 var durationSelector = this.durationSelector;
47                 duration = durationSelector(value);
48             }
49             catch (err) {
50                 return this.destination.error(err);
51             }
52             var innerSubscription = innerSubscribe_1.innerSubscribe(duration, new innerSubscribe_1.SimpleInnerSubscriber(this));
53             if (!innerSubscription || innerSubscription.closed) {
54                 this.clearThrottle();
55             }
56             else {
57                 this.add(this.throttled = innerSubscription);
58             }
59         }
60     };
61     AuditSubscriber.prototype.clearThrottle = function () {
62         var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
63         if (throttled) {
64             this.remove(throttled);
65             this.throttled = undefined;
66             throttled.unsubscribe();
67         }
68         if (hasValue) {
69             this.value = undefined;
70             this.hasValue = false;
71             this.destination.next(value);
72         }
73     };
74     AuditSubscriber.prototype.notifyNext = function () {
75         this.clearThrottle();
76     };
77     AuditSubscriber.prototype.notifyComplete = function () {
78         this.clearThrottle();
79     };
80     return AuditSubscriber;
81 }(innerSubscribe_1.SimpleOuterSubscriber));
82 //# sourceMappingURL=audit.js.map