Skip to content

Commit

Permalink
feat(drop): rename skip() to drop()
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Medeiros committed Mar 26, 2016
1 parent ce92a2f commit cab26a9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Producer} from './Producer';
import {MapOperator} from './operator/MapOperator';
import {FilterOperator} from './operator/FilterOperator';
import {TakeOperator} from './operator/TakeOperator';
import {SkipOperator} from './operator/SkipOperator';
import {DropOperator} from './operator/DropOperator';
import {DebugOperator} from './operator/DebugOperator';
import {FoldOperator} from './operator/FoldOperator';
import {LastOperator} from './operator/LastOperator';
Expand Down Expand Up @@ -143,8 +143,8 @@ export class Stream<T> implements Listener<T> {
return new Stream<T>(new TakeOperator(amount, this));
}

skip(amount: number): Stream<T> {
return new Stream<T>(new SkipOperator(amount, this));
drop(amount: number): Stream<T> {
return new Stream<T>(new DropOperator(amount, this));
}

debug(spy: (t: T) => void = null): Stream<T> {
Expand Down
8 changes: 4 additions & 4 deletions src/operator/SkipOperator.ts → src/operator/DropOperator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {emptyListener} from '../utils/emptyListener';

export class Proxy<T> implements Listener<T> {
constructor(public out: Stream<T>,
public prod: SkipOperator<T>) {
public prod: DropOperator<T>) {
}

next(t: T) {
if (this.prod.skipped++ >= this.prod.max) this.out.next(t);
if (this.prod.dropped++ >= this.prod.max) this.out.next(t);
}

error(err: any) {
Expand All @@ -21,9 +21,9 @@ export class Proxy<T> implements Listener<T> {
}
}

export class SkipOperator<T> implements Operator<T, T> {
export class DropOperator<T> implements Operator<T, T> {
public proxy: Listener<T> = emptyListener;
public skipped: number = 0;
public dropped: number = 0;

constructor(public max: number,
public ins: Stream<T>) {
Expand Down
6 changes: 3 additions & 3 deletions tests/operator/skip.ts → tests/operator/drop.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import xs from '../../src/index';
import * as assert from 'assert';

describe('Stream.prototype.skip', () => {
it('should allow specifying max amount to skip from input stream', (done) => {
const stream = xs.interval(50).skip(4)
describe('Stream.prototype.drop', () => {
it('should allow specifying max amount to drop from input stream', (done) => {
const stream = xs.interval(50).drop(4)
const expected = [4, 5, 6];
let listener = {
next: (x: number) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Stream', () => {
assert.equal(typeof stream.map, 'function');
assert.equal(typeof stream.filter, 'function');
assert.equal(typeof stream.take, 'function');
assert.equal(typeof stream.skip, 'function');
assert.equal(typeof stream.drop, 'function');
assert.equal(typeof stream.debug, 'function');
assert.equal(typeof stream.fold, 'function');
assert.equal(typeof stream.last, 'function');
Expand Down

0 comments on commit cab26a9

Please sign in to comment.