frontend/.pnpm-store/v3/files/2a/f82cd1d1185b6c2e87f7717138f18ce4ea134ccbd8f61f614445ba553a94436874fa29f34908bd3f1459c37845fbeed8c6fb544af93c3936d31718dc8b076e

37 lines
1.0 KiB
Plaintext

import { Subscriber } from '../Subscriber';
export function filter(predicate, thisArg) {
return function filterOperatorFunction(source) {
return source.lift(new FilterOperator(predicate, thisArg));
};
}
class FilterOperator {
constructor(predicate, thisArg) {
this.predicate = predicate;
this.thisArg = thisArg;
}
call(subscriber, source) {
return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
}
}
class FilterSubscriber extends Subscriber {
constructor(destination, predicate, thisArg) {
super(destination);
this.predicate = predicate;
this.thisArg = thisArg;
this.count = 0;
}
_next(value) {
let result;
try {
result = this.predicate.call(this.thisArg, value, this.count++);
}
catch (err) {
this.destination.error(err);
return;
}
if (result) {
this.destination.next(value);
}
}
}
//# sourceMappingURL=filter.js.map