merge.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. /** PURE_IMPORTS_START _Observable,_util_isScheduler,_operators_mergeAll,_fromArray PURE_IMPORTS_END */
  2. import { Observable } from '../Observable';
  3. import { isScheduler } from '../util/isScheduler';
  4. import { mergeAll } from '../operators/mergeAll';
  5. import { fromArray } from './fromArray';
  6. export function merge() {
  7. var observables = [];
  8. for (var _i = 0; _i < arguments.length; _i++) {
  9. observables[_i] = arguments[_i];
  10. }
  11. var concurrent = Number.POSITIVE_INFINITY;
  12. var scheduler = null;
  13. var last = observables[observables.length - 1];
  14. if (isScheduler(last)) {
  15. scheduler = observables.pop();
  16. if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
  17. concurrent = observables.pop();
  18. }
  19. }
  20. else if (typeof last === 'number') {
  21. concurrent = observables.pop();
  22. }
  23. if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
  24. return observables[0];
  25. }
  26. return mergeAll(concurrent)(fromArray(observables, scheduler));
  27. }
  28. //# sourceMappingURL=merge.js.map