Home Manual Reference Source Test Repository

es6/operator/skip.js

import { Subscriber } from '../Subscriber';
/**
 * 返回一个 Observable, 该 Observable 跳过源 Observable 发出的前N个值(N = count)。
 *
 * <img src="./img/skip.png" width="100%">
 *
 * @param {Number} count - 由源 Observable 所发出项应该被跳过的次数。
 * @return {Observable} 跳过源 Observable 发出值的 Observable。
 *
 * @method skip
 * @owner Observable
 */
export function skip(count) {
    return this.lift(new SkipOperator(count));
}
class SkipOperator {
    constructor(total) {
        this.total = total;
    }
    call(subscriber, source) {
        return source.subscribe(new SkipSubscriber(subscriber, this.total));
    }
}
/**
 * We need this JSDoc comment for affecting ESDoc.
 * @ignore
 * @extends {Ignored}
 */
class SkipSubscriber extends Subscriber {
    constructor(destination, total) {
        super(destination);
        this.total = total;
        this.count = 0;
    }
    _next(x) {
        if (++this.count > this.total) {
            this.destination.next(x);
        }
    }
}
//# sourceMappingURL=skip.js.map