Code coverage report for src/operator/toPromise.ts

Statements: 81.25% (13 / 16)      Branches: 63.64% (7 / 11)      Functions: 100% (5 / 5)      Lines: 75% (9 / 12)      Ignored: none     

All files » src/operator/ » toPromise.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211   4 3 1 1           3       3 3 4      
import {root} from '../util/root';
 
export function toPromise<T>(PromiseCtor?: PromiseConstructor): Promise<T> {
  if (!PromiseCtor) {
    Eif (root.Rx && root.Rx.config && root.Rx.config.Promise) {
      PromiseCtor = root.Rx.config.Promise;
    } else if (root.Promise) {
      PromiseCtor = root.Promise;
    }
  }
 
  Iif (!PromiseCtor) {
    throw new Error('no Promise impl found');
  }
 
  return new PromiseCtor((resolve, reject) => {
    let value: any;
    this.subscribe((x: T) => value = x, (err: any) => reject(err), () => resolve(value));
  });
}