File tree Expand file tree Collapse file tree 3 files changed +51
-32
lines changed Expand file tree Collapse file tree 3 files changed +51
-32
lines changed Original file line number Diff line number Diff line change 1- import { Operator } from '../Operator' ;
2- import { Subscriber } from '../Subscriber' ;
31import { Observable } from '../Observable' ;
4- import { TeardownLogic } from '../Subscription ' ;
2+ import { skip as higherOrder } from '../operators/skip ' ;
53
64/**
75 * Returns an Observable that skips the first `count` items emitted by the source Observable.
@@ -15,33 +13,5 @@ import { TeardownLogic } from '../Subscription';
1513 * @owner Observable
1614 */
1715export function skip < T > ( this : Observable < T > , count : number ) : Observable < T > {
18- return this . lift ( new SkipOperator ( count ) ) ;
19- }
20-
21- class SkipOperator < T > implements Operator < T , T > {
22- constructor ( private total : number ) {
23- }
24-
25- call ( subscriber : Subscriber < T > , source : any ) : TeardownLogic {
26- return source . subscribe ( new SkipSubscriber ( subscriber , this . total ) ) ;
27- }
28- }
29-
30- /**
31- * We need this JSDoc comment for affecting ESDoc.
32- * @ignore
33- * @extends {Ignored }
34- */
35- class SkipSubscriber < T > extends Subscriber < T > {
36- count : number = 0 ;
37-
38- constructor ( destination : Subscriber < T > , private total : number ) {
39- super ( destination ) ;
40- }
41-
42- protected _next ( x : T ) {
43- if ( ++ this . count > this . total ) {
44- this . destination . next ( x ) ;
45- }
46- }
16+ return higherOrder ( count ) ( this ) ;
4717}
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ export { race } from './race';
6060export { reduce } from './reduce' ;
6161export { refCount } from './refCount' ;
6262export { scan } from './scan' ;
63+ export { skip } from './skip' ;
6364export { subscribeOn } from './subscribeOn' ;
6465export { switchAll } from './switchAll' ;
6566export { switchMap } from './switchMap' ;
Original file line number Diff line number Diff line change 1+ import { Operator } from '../Operator' ;
2+ import { Subscriber } from '../Subscriber' ;
3+ import { Observable } from '../Observable' ;
4+ import { TeardownLogic } from '../Subscription' ;
5+ import { MonoTypeOperatorFunction } from '../interfaces' ;
6+
7+ /**
8+ * Returns an Observable that skips the first `count` items emitted by the source Observable.
9+ *
10+ * <img src="./img/skip.png" width="100%">
11+ *
12+ * @param {Number } count - The number of times, items emitted by source Observable should be skipped.
13+ * @return {Observable } An Observable that skips values emitted by the source Observable.
14+ *
15+ * @method skip
16+ * @owner Observable
17+ */
18+ export function skip < T > ( count : number ) : MonoTypeOperatorFunction < T > {
19+ return ( source : Observable < T > ) => source . lift ( new SkipOperator ( count ) ) ;
20+ }
21+
22+ class SkipOperator < T > implements Operator < T , T > {
23+ constructor ( private total : number ) {
24+ }
25+
26+ call ( subscriber : Subscriber < T > , source : any ) : TeardownLogic {
27+ return source . subscribe ( new SkipSubscriber ( subscriber , this . total ) ) ;
28+ }
29+ }
30+
31+ /**
32+ * We need this JSDoc comment for affecting ESDoc.
33+ * @ignore
34+ * @extends {Ignored }
35+ */
36+ class SkipSubscriber < T > extends Subscriber < T > {
37+ count : number = 0 ;
38+
39+ constructor ( destination : Subscriber < T > , private total : number ) {
40+ super ( destination ) ;
41+ }
42+
43+ protected _next ( x : T ) {
44+ if ( ++ this . count > this . total ) {
45+ this . destination . next ( x ) ;
46+ }
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments