a zip code crypto-currency system good for red ONLY

startWith.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /** PURE_IMPORTS_START .._observable_ArrayObservable,.._observable_ScalarObservable,.._observable_EmptyObservable,.._observable_concat,.._util_isScheduler PURE_IMPORTS_END */
  2. import { ArrayObservable } from '../observable/ArrayObservable';
  3. import { ScalarObservable } from '../observable/ScalarObservable';
  4. import { EmptyObservable } from '../observable/EmptyObservable';
  5. import { concat as concatStatic } from '../observable/concat';
  6. import { isScheduler } from '../util/isScheduler';
  7. /* tslint:enable:max-line-length */
  8. /**
  9. * Returns an Observable that emits the items you specify as arguments before it begins to emit
  10. * items emitted by the source Observable.
  11. *
  12. * <img src="./img/startWith.png" width="100%">
  13. *
  14. * @param {...T} values - Items you want the modified Observable to emit first.
  15. * @param {Scheduler} [scheduler] - A {@link IScheduler} to use for scheduling
  16. * the emissions of the `next` notifications.
  17. * @return {Observable} An Observable that emits the items in the specified Iterable and then emits the items
  18. * emitted by the source Observable.
  19. * @method startWith
  20. * @owner Observable
  21. */
  22. export function startWith() {
  23. var array = [];
  24. for (var _i = 0; _i < arguments.length; _i++) {
  25. array[_i - 0] = arguments[_i];
  26. }
  27. return function (source) {
  28. var scheduler = array[array.length - 1];
  29. if (isScheduler(scheduler)) {
  30. array.pop();
  31. }
  32. else {
  33. scheduler = null;
  34. }
  35. var len = array.length;
  36. if (len === 1) {
  37. return concatStatic(new ScalarObservable(array[0], scheduler), source);
  38. }
  39. else if (len > 1) {
  40. return concatStatic(new ArrayObservable(array, scheduler), source);
  41. }
  42. else {
  43. return concatStatic(new EmptyObservable(scheduler), source);
  44. }
  45. };
  46. }
  47. //# sourceMappingURL=startWith.js.map