a zip code crypto-currency system good for red ONLY

mergeScan.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { mergeScan as higherOrder } from '../operators/mergeScan';
  2. /**
  3. * Applies an accumulator function over the source Observable where the
  4. * accumulator function itself returns an Observable, then each intermediate
  5. * Observable returned is merged into the output Observable.
  6. *
  7. * <span class="informal">It's like {@link scan}, but the Observables returned
  8. * by the accumulator are merged into the outer Observable.</span>
  9. *
  10. * @example <caption>Count the number of click events</caption>
  11. * const click$ = Rx.Observable.fromEvent(document, 'click');
  12. * const one$ = click$.mapTo(1);
  13. * const seed = 0;
  14. * const count$ = one$.mergeScan((acc, one) => Rx.Observable.of(acc + one), seed);
  15. * count$.subscribe(x => console.log(x));
  16. *
  17. * // Results:
  18. * 1
  19. * 2
  20. * 3
  21. * 4
  22. * // ...and so on for each click
  23. *
  24. * @param {function(acc: R, value: T): Observable<R>} accumulator
  25. * The accumulator function called on each source value.
  26. * @param seed The initial accumulation value.
  27. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of
  28. * input Observables being subscribed to concurrently.
  29. * @return {Observable<R>} An observable of the accumulated values.
  30. * @method mergeScan
  31. * @owner Observable
  32. */
  33. export function mergeScan(accumulator, seed, concurrent = Number.POSITIVE_INFINITY) {
  34. return higherOrder(accumulator, seed, concurrent)(this);
  35. }
  36. //# sourceMappingURL=mergeScan.js.map