frontend/.pnpm-store/v3/files/49/f2d53937eaead6cfd2ec67e7f86545ff101757d52dd013839b9f3286967237aac599b9212c73f5f64577090c9d633641cefbd7c2f09e7bdf10d411998d701e

22 lines
857 B
Plaintext

import { identity } from '../util/identity';
import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function distinctUntilChanged(comparator, keySelector = identity) {
comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
return operate((source, subscriber) => {
let previousKey;
let first = true;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const currentKey = keySelector(value);
if (first || !comparator(previousKey, currentKey)) {
first = false;
previousKey = currentKey;
subscriber.next(value);
}
}));
});
}
function defaultCompare(a, b) {
return a === b;
}
//# sourceMappingURL=distinctUntilChanged.js.map