1 | "use strict";
|
---|
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);
|
---|
8 | }
|
---|
9 | return function (d, b) {
|
---|
10 | extendStatics(d, b);
|
---|
11 | function __() { this.constructor = d; }
|
---|
12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
13 | };
|
---|
14 | })();
|
---|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
16 | var Subscriber_1 = require("../Subscriber");
|
---|
17 | function skipWhile(predicate) {
|
---|
18 | return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
|
---|
19 | }
|
---|
20 | exports.skipWhile = skipWhile;
|
---|
21 | var SkipWhileOperator = (function () {
|
---|
22 | function SkipWhileOperator(predicate) {
|
---|
23 | this.predicate = predicate;
|
---|
24 | }
|
---|
25 | SkipWhileOperator.prototype.call = function (subscriber, source) {
|
---|
26 | return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
|
---|
27 | };
|
---|
28 | return SkipWhileOperator;
|
---|
29 | }());
|
---|
30 | var SkipWhileSubscriber = (function (_super) {
|
---|
31 | __extends(SkipWhileSubscriber, _super);
|
---|
32 | function SkipWhileSubscriber(destination, predicate) {
|
---|
33 | var _this = _super.call(this, destination) || this;
|
---|
34 | _this.predicate = predicate;
|
---|
35 | _this.skipping = true;
|
---|
36 | _this.index = 0;
|
---|
37 | return _this;
|
---|
38 | }
|
---|
39 | SkipWhileSubscriber.prototype._next = function (value) {
|
---|
40 | var destination = this.destination;
|
---|
41 | if (this.skipping) {
|
---|
42 | this.tryCallPredicate(value);
|
---|
43 | }
|
---|
44 | if (!this.skipping) {
|
---|
45 | destination.next(value);
|
---|
46 | }
|
---|
47 | };
|
---|
48 | SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
|
---|
49 | try {
|
---|
50 | var result = this.predicate(value, this.index++);
|
---|
51 | this.skipping = Boolean(result);
|
---|
52 | }
|
---|
53 | catch (err) {
|
---|
54 | this.destination.error(err);
|
---|
55 | }
|
---|
56 | };
|
---|
57 | return SkipWhileSubscriber;
|
---|
58 | }(Subscriber_1.Subscriber));
|
---|
59 | //# sourceMappingURL=skipWhile.js.map |
---|