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

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

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subscriber } from '../Subscriber';
4export function distinctUntilChanged(compare, keySelector) {
5 return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
6}
7var DistinctUntilChangedOperator = /*@__PURE__*/ (function () {
8 function DistinctUntilChangedOperator(compare, keySelector) {
9 this.compare = compare;
10 this.keySelector = keySelector;
11 }
12 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
13 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
14 };
15 return DistinctUntilChangedOperator;
16}());
17var DistinctUntilChangedSubscriber = /*@__PURE__*/ (function (_super) {
18 tslib_1.__extends(DistinctUntilChangedSubscriber, _super);
19 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
20 var _this = _super.call(this, destination) || this;
21 _this.keySelector = keySelector;
22 _this.hasKey = false;
23 if (typeof compare === 'function') {
24 _this.compare = compare;
25 }
26 return _this;
27 }
28 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
29 return x === y;
30 };
31 DistinctUntilChangedSubscriber.prototype._next = function (value) {
32 var key;
33 try {
34 var keySelector = this.keySelector;
35 key = keySelector ? keySelector(value) : value;
36 }
37 catch (err) {
38 return this.destination.error(err);
39 }
40 var result = false;
41 if (this.hasKey) {
42 try {
43 var compare = this.compare;
44 result = compare(this.key, key);
45 }
46 catch (err) {
47 return this.destination.error(err);
48 }
49 }
50 else {
51 this.hasKey = true;
52 }
53 if (!result) {
54 this.key = key;
55 this.destination.next(value);
56 }
57 };
58 return DistinctUntilChangedSubscriber;
59}(Subscriber));
60//# sourceMappingURL=distinctUntilChanged.js.map
Note: See TracBrowser for help on using the repository browser.