2 var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var Subscriber_1 = require("../Subscriber");
17 function takeWhile(predicate, inclusive) {
18 if (inclusive === void 0) { inclusive = false; }
19 return function (source) {
20 return source.lift(new TakeWhileOperator(predicate, inclusive));
23 exports.takeWhile = takeWhile;
24 var TakeWhileOperator = (function () {
25 function TakeWhileOperator(predicate, inclusive) {
26 this.predicate = predicate;
27 this.inclusive = inclusive;
29 TakeWhileOperator.prototype.call = function (subscriber, source) {
30 return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
32 return TakeWhileOperator;
34 var TakeWhileSubscriber = (function (_super) {
35 __extends(TakeWhileSubscriber, _super);
36 function TakeWhileSubscriber(destination, predicate, inclusive) {
37 var _this = _super.call(this, destination) || this;
38 _this.predicate = predicate;
39 _this.inclusive = inclusive;
43 TakeWhileSubscriber.prototype._next = function (value) {
44 var destination = this.destination;
47 result = this.predicate(value, this.index++);
50 destination.error(err);
53 this.nextOrComplete(value, result);
55 TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
56 var destination = this.destination;
57 if (Boolean(predicateResult)) {
58 destination.next(value);
62 destination.next(value);
64 destination.complete();
67 return TakeWhileSubscriber;
68 }(Subscriber_1.Subscriber));
69 //# sourceMappingURL=takeWhile.js.map