Bones/node_modules/rxjs/operator/pairwise.js
SOUTHERNCO\x2mjbyrn 7efe7605b8 Template Upload
2017-05-17 13:45:25 -04:00

46 lines
1.5 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');
/**
* Returns a new observable that triggers on the second and following inputs.
* An input that triggers an event will return an pair of [(N - 1)th, Nth].
* The (N-1)th is stored in the internal state until Nth input occurs.
*
* <img src="./img/pairwise.png" width="100%">
*
* @returns {Observable<R>} an observable of pairs of values.
*/
function pairwise() {
return this.lift(new PairwiseOperator());
}
exports.pairwise = pairwise;
var PairwiseOperator = (function () {
function PairwiseOperator() {
}
PairwiseOperator.prototype.call = function (subscriber) {
return new PairwiseSubscriber(subscriber);
};
return PairwiseOperator;
}());
var PairwiseSubscriber = (function (_super) {
__extends(PairwiseSubscriber, _super);
function PairwiseSubscriber(destination) {
_super.call(this, destination);
this.hasPrev = false;
}
PairwiseSubscriber.prototype._next = function (value) {
if (this.hasPrev) {
this.destination.next([this.prev, value]);
}
else {
this.hasPrev = true;
}
this.prev = value;
};
return PairwiseSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=pairwise.js.map