es6/operator/skip.js
import { Subscriber } from '../Subscriber';
/**
* Returns an Observable that skips `n` items emitted by an Observable.
*
* <img src="./img/skip.png" width="100%">
*
* @param {Number} the `n` of times, items emitted by source Observable should be skipped.
* @return {Observable} an Observable that skips values emitted by the source Observable.
*
* @method skip
* @owner Observable
*/
export function skip(total) {
return this.lift(new SkipOperator(total));
}
var SkipOperator = (function () {
function SkipOperator(total) {
this.total = total;
}
SkipOperator.prototype.call = function (subscriber, source) {
return source._subscribe(new SkipSubscriber(subscriber, this.total));
};
return SkipOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var SkipSubscriber = (function (_super) {
__extends(SkipSubscriber, _super);
function SkipSubscriber(destination, total) {
_super.call(this, destination);
this.total = total;
this.count = 0;
}
SkipSubscriber.prototype._next = function (x) {
if (++this.count > this.total) {
this.destination.next(x);
}
};
return SkipSubscriber;
}(Subscriber));
//# sourceMappingURL=skip.js.map