source: trip-planner-front/node_modules/rxjs/internal/operators/distinctUntilChanged.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 2.7 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 Subscriber_1 = require("../Subscriber");
17function distinctUntilChanged(compare, keySelector) {
18 return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
19}
20exports.distinctUntilChanged = distinctUntilChanged;
21var DistinctUntilChangedOperator = (function () {
22 function DistinctUntilChangedOperator(compare, keySelector) {
23 this.compare = compare;
24 this.keySelector = keySelector;
25 }
26 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
27 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
28 };
29 return DistinctUntilChangedOperator;
30}());
31var DistinctUntilChangedSubscriber = (function (_super) {
32 __extends(DistinctUntilChangedSubscriber, _super);
33 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
34 var _this = _super.call(this, destination) || this;
35 _this.keySelector = keySelector;
36 _this.hasKey = false;
37 if (typeof compare === 'function') {
38 _this.compare = compare;
39 }
40 return _this;
41 }
42 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
43 return x === y;
44 };
45 DistinctUntilChangedSubscriber.prototype._next = function (value) {
46 var key;
47 try {
48 var keySelector = this.keySelector;
49 key = keySelector ? keySelector(value) : value;
50 }
51 catch (err) {
52 return this.destination.error(err);
53 }
54 var result = false;
55 if (this.hasKey) {
56 try {
57 var compare = this.compare;
58 result = compare(this.key, key);
59 }
60 catch (err) {
61 return this.destination.error(err);
62 }
63 }
64 else {
65 this.hasKey = true;
66 }
67 if (!result) {
68 this.key = key;
69 this.destination.next(value);
70 }
71 };
72 return DistinctUntilChangedSubscriber;
73}(Subscriber_1.Subscriber));
74//# sourceMappingURL=distinctUntilChanged.js.map
Note: See TracBrowser for help on using the repository browser.