Every new change
This commit is contained in:
60
node_modules/rxjs/_esm5/internal/operators/distinctUntilChanged.js
generated
vendored
Normal file
60
node_modules/rxjs/_esm5/internal/operators/distinctUntilChanged.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
|
||||
import * as tslib_1 from "tslib";
|
||||
import { Subscriber } from '../Subscriber';
|
||||
export function distinctUntilChanged(compare, keySelector) {
|
||||
return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
|
||||
}
|
||||
var DistinctUntilChangedOperator = /*@__PURE__*/ (function () {
|
||||
function DistinctUntilChangedOperator(compare, keySelector) {
|
||||
this.compare = compare;
|
||||
this.keySelector = keySelector;
|
||||
}
|
||||
DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
|
||||
return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
|
||||
};
|
||||
return DistinctUntilChangedOperator;
|
||||
}());
|
||||
var DistinctUntilChangedSubscriber = /*@__PURE__*/ (function (_super) {
|
||||
tslib_1.__extends(DistinctUntilChangedSubscriber, _super);
|
||||
function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
|
||||
var _this = _super.call(this, destination) || this;
|
||||
_this.keySelector = keySelector;
|
||||
_this.hasKey = false;
|
||||
if (typeof compare === 'function') {
|
||||
_this.compare = compare;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
|
||||
return x === y;
|
||||
};
|
||||
DistinctUntilChangedSubscriber.prototype._next = function (value) {
|
||||
var key;
|
||||
try {
|
||||
var keySelector = this.keySelector;
|
||||
key = keySelector ? keySelector(value) : value;
|
||||
}
|
||||
catch (err) {
|
||||
return this.destination.error(err);
|
||||
}
|
||||
var result = false;
|
||||
if (this.hasKey) {
|
||||
try {
|
||||
var compare = this.compare;
|
||||
result = compare(this.key, key);
|
||||
}
|
||||
catch (err) {
|
||||
return this.destination.error(err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.hasKey = true;
|
||||
}
|
||||
if (!result) {
|
||||
this.key = key;
|
||||
this.destination.next(value);
|
||||
}
|
||||
};
|
||||
return DistinctUntilChangedSubscriber;
|
||||
}(Subscriber));
|
||||
//# sourceMappingURL=distinctUntilChanged.js.map
|
Reference in New Issue
Block a user