Code coverage report for src/util/toSubscriber.ts

Statements: 100% (10 / 10)      Branches: 100% (8 / 8)      Functions: 100% (1 / 1)      Lines: 100% (9 / 9)      Ignored: none     

All files » src/util/ » toSubscriber.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  1 1   1         7886 5531 5327 204 184       2375    
import {Observer} from '../Observer';
import {Subscriber} from '../Subscriber';
import {rxSubscriber} from '../symbol/rxSubscriber';
 
export function toSubscriber<T>(
  next?: Observer<T> | ((value: T) => void),
  error?: (error: any) => void,
  complete?: () => void): Subscriber<T> {
 
  if (next && typeof next === 'object') {
    if (next instanceof Subscriber) {
      return (<Subscriber<T>> next);
    } else if (typeof next[rxSubscriber] === 'function') {
      return next[rxSubscriber]();
    }
  }
 
  return new Subscriber(next, error, complete);
}