SOUTHERNCO\x2mjbyrn 7efe7605b8 Template Upload
2017-05-17 13:45:25 -04:00

51 lines
1.7 KiB
JavaScript

"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = require('../Subscriber');
function takeWhile(predicate) {
return this.lift(new TakeWhileOperator(predicate));
}
exports.takeWhile = takeWhile;
var TakeWhileOperator = (function () {
function TakeWhileOperator(predicate) {
this.predicate = predicate;
}
TakeWhileOperator.prototype.call = function (subscriber) {
return new TakeWhileSubscriber(subscriber, this.predicate);
};
return TakeWhileOperator;
}());
var TakeWhileSubscriber = (function (_super) {
__extends(TakeWhileSubscriber, _super);
function TakeWhileSubscriber(destination, predicate) {
_super.call(this, destination);
this.predicate = predicate;
this.index = 0;
}
TakeWhileSubscriber.prototype._next = function (value) {
var destination = this.destination;
var result;
try {
result = this.predicate(value, this.index++);
}
catch (err) {
destination.error(err);
return;
}
this.nextOrComplete(value, result);
};
TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
var destination = this.destination;
if (Boolean(predicateResult)) {
destination.next(value);
}
else {
destination.complete();
}
};
return TakeWhileSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=takeWhile.js.map