source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/count.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subscriber } from '../Subscriber';
4export function count(predicate) {
5 return function (source) { return source.lift(new CountOperator(predicate, source)); };
6}
7var CountOperator = /*@__PURE__*/ (function () {
8 function CountOperator(predicate, source) {
9 this.predicate = predicate;
10 this.source = source;
11 }
12 CountOperator.prototype.call = function (subscriber, source) {
13 return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
14 };
15 return CountOperator;
16}());
17var 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;
23 _this.count = 0;
24 _this.index = 0;
25 return _this;
26 }
27 CountSubscriber.prototype._next = function (value) {
28 if (this.predicate) {
29 this._tryPredicate(value);
30 }
31 else {
32 this.count++;
33 }
34 };
35 CountSubscriber.prototype._tryPredicate = function (value) {
36 var result;
37 try {
38 result = this.predicate(value, this.index++, this.source);
39 }
40 catch (err) {
41 this.destination.error(err);
42 return;
43 }
44 if (result) {
45 this.count++;
46 }
47 };
48 CountSubscriber.prototype._complete = function () {
49 this.destination.next(this.count);
50 this.destination.complete();
51 };
52 return CountSubscriber;
53}(Subscriber));
54//# sourceMappingURL=count.js.map
Note: See TracBrowser for help on using the repository browser.