source: trip-planner-front/node_modules/rxjs/internal/operators/audit.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1"use strict";
2var __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})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var innerSubscribe_1 = require("../innerSubscribe");
17function audit(durationSelector) {
18 return function auditOperatorFunction(source) {
19 return source.lift(new AuditOperator(durationSelector));
20 };
21}
22exports.audit = audit;
23var 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}());
32var 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
Note: See TracBrowser for help on using the repository browser.