Code coverage report for src/operator/startWith.ts

Statements: 100% (18 / 18)      Branches: 100% (6 / 6)      Functions: 100% (1 / 1)      Lines: 100% (16 / 16)      Ignored: none     

All files » src/operator/ » startWith.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    1 1 1 1 1   55 25 25 4   21     25 25 22 3 2   1      
import {Scheduler} from '../Scheduler';
import {Observable} from '../Observable';
import {ArrayObservable} from '../observable/fromArray';
import {ScalarObservable} from '../observable/ScalarObservable';
import {EmptyObservable} from '../observable/empty';
import {concat} from './concat-static';
import {isScheduler} from '../util/isScheduler';
 
export function startWith<T>(...array: (T | Scheduler)[]): Observable<T> {
  let scheduler = <Scheduler>array[array.length - 1];
  if (isScheduler(scheduler)) {
    array.pop();
  } else {
    scheduler = void 0;
  }
 
  const len = array.length;
  if (len === 1) {
    return concat(new ScalarObservable(array[0], scheduler), this);
  } else if (len > 1) {
    return concat(new ArrayObservable(array, scheduler), this);
  } else {
    return concat(new EmptyObservable(scheduler), this);
  }
}