blob: b442c0034037491160c830df2232c81b17de5be9 [file] [log] [blame]
/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
import * as tslib_1 from "tslib";
import { Subscriber } from '../Subscriber';
export function filter(predicate, thisArg) {
return function filterOperatorFunction(source) {
return source.lift(new FilterOperator(predicate, thisArg));
};
}
var FilterOperator = /*@__PURE__*/ (function () {
function FilterOperator(predicate, thisArg) {
this.predicate = predicate;
this.thisArg = thisArg;
}
FilterOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
};
return FilterOperator;
}());
var FilterSubscriber = /*@__PURE__*/ (function (_super) {
tslib_1.__extends(FilterSubscriber, _super);
function FilterSubscriber(destination, predicate, thisArg) {
var _this = _super.call(this, destination) || this;
_this.predicate = predicate;
_this.thisArg = thisArg;
_this.count = 0;
return _this;
}
FilterSubscriber.prototype._next = function (value) {
var result;
try {
result = this.predicate.call(this.thisArg, value, this.count++);
}
catch (err) {
this.destination.error(err);
return;
}
if (result) {
this.destination.next(value);
}
};
return FilterSubscriber;
}(Subscriber));
//# sourceMappingURL=filter.js.map