wishthis/node_modules/rxjs/dist/cjs/internal/operators/distinct.js

22 lines
1,000 B
JavaScript
Raw Normal View History

2022-06-08 10:36:39 +00:00
"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");
2023-02-08 12:35:10 +00:00
var innerFrom_1 = require("../observable/innerFrom");
2022-06-08 10:36:39 +00:00
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);
}
}));
2023-02-08 12:35:10 +00:00
flushes && innerFrom_1.innerFrom(flushes).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () { return distinctKeys.clear(); }, noop_1.noop));
2022-06-08 10:36:39 +00:00
});
}
exports.distinct = distinct;
//# sourceMappingURL=distinct.js.map