Actualizacion maquina principal
[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 OuterSubscriber_1 = require("../OuterSubscriber");
17 var subscribeToResult_1 = require("../util/subscribeToResult");
18 function audit(durationSelector) {
19     return function auditOperatorFunction(source) {
20         return source.lift(new AuditOperator(durationSelector));
21     };
22 }
23 exports.audit = audit;
24 var AuditOperator = (function () {
25     function AuditOperator(durationSelector) {
26         this.durationSelector = durationSelector;
27     }
28     AuditOperator.prototype.call = function (subscriber, source) {
29         return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
30     };
31     return AuditOperator;
32 }());
33 var AuditSubscriber = (function (_super) {
34     __extends(AuditSubscriber, _super);
35     function AuditSubscriber(destination, durationSelector) {
36         var _this = _super.call(this, destination) || this;
37         _this.durationSelector = durationSelector;
38         _this.hasValue = false;
39         return _this;
40     }
41     AuditSubscriber.prototype._next = function (value) {
42         this.value = value;
43         this.hasValue = true;
44         if (!this.throttled) {
45             var duration = void 0;
46             try {
47                 var durationSelector = this.durationSelector;
48                 duration = durationSelector(value);
49             }
50             catch (err) {
51                 return this.destination.error(err);
52             }
53             var innerSubscription = subscribeToResult_1.subscribeToResult(this, duration);
54             if (!innerSubscription || innerSubscription.closed) {
55                 this.clearThrottle();
56             }
57             else {
58                 this.add(this.throttled = innerSubscription);
59             }
60         }
61     };
62     AuditSubscriber.prototype.clearThrottle = function () {
63         var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
64         if (throttled) {
65             this.remove(throttled);
66             this.throttled = null;
67             throttled.unsubscribe();
68         }
69         if (hasValue) {
70             this.value = null;
71             this.hasValue = false;
72             this.destination.next(value);
73         }
74     };
75     AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
76         this.clearThrottle();
77     };
78     AuditSubscriber.prototype.notifyComplete = function () {
79         this.clearThrottle();
80     };
81     return AuditSubscriber;
82 }(OuterSubscriber_1.OuterSubscriber));
83 //# sourceMappingURL=audit.js.map