1 import { Operator } from '../Operator';
2 import { Subscriber } from '../Subscriber';
3 import { Observable } from '../Observable';
4 import { MonoTypeOperatorFunction, TeardownLogic } from '../types';
7 * Returns an Observable that skips the first `count` items emitted by the source Observable.
11 * @param {Number} count - The number of times, items emitted by source Observable should be skipped.
12 * @return {Observable} An Observable that skips values emitted by the source Observable.
17 export function skip<T>(count: number): MonoTypeOperatorFunction<T> {
18 return (source: Observable<T>) => source.lift(new SkipOperator(count));
21 class SkipOperator<T> implements Operator<T, T> {
22 constructor(private total: number) {
25 call(subscriber: Subscriber<T>, source: any): TeardownLogic {
26 return source.subscribe(new SkipSubscriber(subscriber, this.total));
31 * We need this JSDoc comment for affecting ESDoc.
35 class SkipSubscriber<T> extends Subscriber<T> {
38 constructor(destination: Subscriber<T>, private total: number) {
42 protected _next(x: T) {
43 if (++this.count > this.total) {
44 this.destination.next(x);