{"ast":null,"code":"import { Subscriber } from '../Subscriber';\nexport function count(predicate) {\n  return source => source.lift(new CountOperator(predicate, source));\n}\n\nclass CountOperator {\n  constructor(predicate, source) {\n    this.predicate = predicate;\n    this.source = source;\n  }\n\n  call(subscriber, source) {\n    return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));\n  }\n\n}\n\nclass CountSubscriber extends Subscriber {\n  constructor(destination, predicate, source) {\n    super(destination);\n    this.predicate = predicate;\n    this.source = source;\n    this.count = 0;\n    this.index = 0;\n  }\n\n  _next(value) {\n    if (this.predicate) {\n      this._tryPredicate(value);\n    } else {\n      this.count++;\n    }\n  }\n\n  _tryPredicate(value) {\n    let result;\n\n    try {\n      result = this.predicate(value, this.index++, this.source);\n    } catch (err) {\n      this.destination.error(err);\n      return;\n    }\n\n    if (result) {\n      this.count++;\n    }\n  }\n\n  _complete() {\n    this.destination.next(this.count);\n    this.destination.complete();\n  }\n\n} //# sourceMappingURL=count.js.map","map":null,"metadata":{},"sourceType":"module"}