Skip to content

Commit

Permalink
perf(operator): fix all operators to refer this.proxy initially to em…
Browse files Browse the repository at this point in the history
…ptyObserver
  • Loading branch information
Andre Medeiros committed Feb 26, 2016
1 parent 57453f2 commit ad210fc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/operator/DebugMachine.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Observer} from '../Observer';
import {Machine} from '../Machine';
import {Stream} from '../Stream';
import {emptyObserver} from '../utils/emptyObserver';

export class DebugMachine<T> implements Machine<T> {
public proxy: Observer<T>;

constructor(public spy: (t: T) => void = null,
public inStream: Stream<T>) {
this.proxy = emptyObserver;
}

start(outStream: Stream<T>): void {
Expand Down
2 changes: 2 additions & 0 deletions src/operator/FilterMachine.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Observer} from '../Observer';
import {Machine} from '../Machine';
import {Stream} from '../Stream';
import {emptyObserver} from '../utils/emptyObserver';

export class FilterMachine<T> implements Machine<T> {
public proxy: Observer<T>;

constructor(public predicate: (t: T) => boolean,
public inStream: Stream<T>) {
this.proxy = emptyObserver;
}

start(outStream: Stream<T>): void {
Expand Down
2 changes: 1 addition & 1 deletion src/operator/FoldMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class FoldMachine<T, R> implements Machine<R> {
outStream.next(this.initAcc);
this.proxy = {
next: (t: T) => {
this.acc = this.accumulator(this.acc, t)
this.acc = this.accumulator(this.acc, t);
outStream.next(this.acc);
},
error: (err) => outStream.error(err),
Expand Down
2 changes: 2 additions & 0 deletions src/operator/MapMachine.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Observer} from '../Observer';
import {Machine} from '../Machine';
import {Stream} from '../Stream';
import {emptyObserver} from '../utils/emptyObserver';

export class MapMachine<T, U> implements Machine<U> {
public proxy: Observer<T>;

constructor(public projection: (t: T) => U,
public inStream: Stream<T>) {
this.proxy = emptyObserver;
}

start(outStream: Stream<U>): void {
Expand Down
2 changes: 2 additions & 0 deletions src/operator/SkipMachine.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {Observer} from '../Observer';
import {Machine} from '../Machine';
import {Stream} from '../Stream';
import {emptyObserver} from '../utils/emptyObserver';

export class SkipMachine<T> implements Machine<T> {
public proxy: Observer<T>;
public skipped: number;

constructor(public max: number,
public inStream: Stream<T>) {
this.proxy = emptyObserver;
this.skipped = 0;
}

Expand Down
2 changes: 2 additions & 0 deletions src/operator/TakeMachine.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {Observer} from '../Observer';
import {Machine} from '../Machine';
import {Stream} from '../Stream';
import {emptyObserver} from '../utils/emptyObserver';

export class TakeMachine<T> implements Machine<T> {
public proxy: Observer<T>;
public taken: number;

constructor(public max: number,
public inStream: Stream<T>) {
this.proxy = emptyObserver;
this.taken = 0;
}

Expand Down

0 comments on commit ad210fc

Please sign in to comment.