1 /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { Subscriber } from '../Subscriber';
4 export function count(predicate) {
5 return function (source) { return source.lift(new CountOperator(predicate, source)); };
7 var CountOperator = /*@__PURE__*/ (function () {
8 function CountOperator(predicate, source) {
9 this.predicate = predicate;
12 CountOperator.prototype.call = function (subscriber, source) {
13 return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
17 var CountSubscriber = /*@__PURE__*/ (function (_super) {
18 tslib_1.__extends(CountSubscriber, _super);
19 function CountSubscriber(destination, predicate, source) {
20 var _this = _super.call(this, destination) || this;
21 _this.predicate = predicate;
22 _this.source = source;
27 CountSubscriber.prototype._next = function (value) {
29 this._tryPredicate(value);
35 CountSubscriber.prototype._tryPredicate = function (value) {
38 result = this.predicate(value, this.index++, this.source);
41 this.destination.error(err);
48 CountSubscriber.prototype._complete = function () {
49 this.destination.next(this.count);
50 this.destination.complete();
52 return CountSubscriber;
54 //# sourceMappingURL=count.js.map