Code coverage report for src/operator/toArray.ts

Statements: 100% (19 / 19)      Branches: 100% (0 / 0)      Functions: 100% (7 / 7)      Lines: 100% (17 / 17)      Ignored: none     

All files » src/operator/ » toArray.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  1   1 12     2 1 12   1   1   12   1 12     1 17     1 7 7   1  
import {Operator} from '../Operator';
import {Subscriber} from '../Subscriber';
 
export function toArray() {
  return this.lift(new ToArrayOperator());
}
 
class ToArrayOperator<T, R> implements Operator<T, R> {
  call(subscriber: Subscriber<T[]>): Subscriber<T> {
    return new ToArraySubscriber<T>(subscriber);
  }
}
 
class ToArraySubscriber<T> extends Subscriber<T> {
 
  array: T [] = [];
 
  constructor(destination: Subscriber<T[]>) {
    super(destination);
  }
 
  _next(x) {
    this.array.push(x);
  }
 
  _complete() {
    this.destination.next(this.array);
    this.destination.complete();
  }
}