wishthis/node_modules/rxjs/dist/cjs/internal/operators/distinct.js
2023-02-08 13:35:10 +01:00

22 lines
No EOL
1,000 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.distinct = void 0;
var lift_1 = require("../util/lift");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var noop_1 = require("../util/noop");
var innerFrom_1 = require("../observable/innerFrom");
function distinct(keySelector, flushes) {
return lift_1.operate(function (source, subscriber) {
var distinctKeys = new Set();
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
var key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
subscriber.next(value);
}
}));
flushes && innerFrom_1.innerFrom(flushes).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () { return distinctKeys.clear(); }, noop_1.noop));
});
}
exports.distinct = distinct;
//# sourceMappingURL=distinct.js.map