source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/takeWhile.js

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

initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subscriber } from '../Subscriber';
4export function takeWhile(predicate, inclusive) {
5 if (inclusive === void 0) {
6 inclusive = false;
7 }
8 return function (source) {
9 return source.lift(new TakeWhileOperator(predicate, inclusive));
10 };
11}
12var TakeWhileOperator = /*@__PURE__*/ (function () {
13 function TakeWhileOperator(predicate, inclusive) {
14 this.predicate = predicate;
15 this.inclusive = inclusive;
16 }
17 TakeWhileOperator.prototype.call = function (subscriber, source) {
18 return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
19 };
20 return TakeWhileOperator;
21}());
22var TakeWhileSubscriber = /*@__PURE__*/ (function (_super) {
23 tslib_1.__extends(TakeWhileSubscriber, _super);
24 function TakeWhileSubscriber(destination, predicate, inclusive) {
25 var _this = _super.call(this, destination) || this;
26 _this.predicate = predicate;
27 _this.inclusive = inclusive;
28 _this.index = 0;
29 return _this;
30 }
31 TakeWhileSubscriber.prototype._next = function (value) {
32 var destination = this.destination;
33 var result;
34 try {
35 result = this.predicate(value, this.index++);
36 }
37 catch (err) {
38 destination.error(err);
39 return;
40 }
41 this.nextOrComplete(value, result);
42 };
43 TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
44 var destination = this.destination;
45 if (Boolean(predicateResult)) {
46 destination.next(value);
47 }
48 else {
49 if (this.inclusive) {
50 destination.next(value);
51 }
52 destination.complete();
53 }
54 };
55 return TakeWhileSubscriber;
56}(Subscriber));
57//# sourceMappingURL=takeWhile.js.map
Note: See TracBrowser for help on using the repository browser.