a zip code crypto-currency system good for red ONLY

windowCount.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { windowCount as higherOrder } from '../operators/windowCount';
  2. /**
  3. * Branch out the source Observable values as a nested Observable with each
  4. * nested Observable emitting at most `windowSize` values.
  5. *
  6. * <span class="informal">It's like {@link bufferCount}, but emits a nested
  7. * Observable instead of an array.</span>
  8. *
  9. * <img src="./img/windowCount.png" width="100%">
  10. *
  11. * Returns an Observable that emits windows of items it collects from the source
  12. * Observable. The output Observable emits windows every `startWindowEvery`
  13. * items, each containing no more than `windowSize` items. When the source
  14. * Observable completes or encounters an error, the output Observable emits
  15. * the current window and propagates the notification from the source
  16. * Observable. If `startWindowEvery` is not provided, then new windows are
  17. * started immediately at the start of the source and when each window completes
  18. * with size `windowSize`.
  19. *
  20. * @example <caption>Ignore every 3rd click event, starting from the first one</caption>
  21. * var clicks = Rx.Observable.fromEvent(document, 'click');
  22. * var result = clicks.windowCount(3)
  23. * .map(win => win.skip(1)) // skip first of every 3 clicks
  24. * .mergeAll(); // flatten the Observable-of-Observables
  25. * result.subscribe(x => console.log(x));
  26. *
  27. * @example <caption>Ignore every 3rd click event, starting from the third one</caption>
  28. * var clicks = Rx.Observable.fromEvent(document, 'click');
  29. * var result = clicks.windowCount(2, 3)
  30. * .mergeAll(); // flatten the Observable-of-Observables
  31. * result.subscribe(x => console.log(x));
  32. *
  33. * @see {@link window}
  34. * @see {@link windowTime}
  35. * @see {@link windowToggle}
  36. * @see {@link windowWhen}
  37. * @see {@link bufferCount}
  38. *
  39. * @param {number} windowSize The maximum number of values emitted by each
  40. * window.
  41. * @param {number} [startWindowEvery] Interval at which to start a new window.
  42. * For example if `startWindowEvery` is `2`, then a new window will be started
  43. * on every other value from the source. A new window is started at the
  44. * beginning of the source by default.
  45. * @return {Observable<Observable<T>>} An Observable of windows, which in turn
  46. * are Observable of values.
  47. * @method windowCount
  48. * @owner Observable
  49. */
  50. export function windowCount(windowSize, startWindowEvery = 0) {
  51. return higherOrder(windowSize, startWindowEvery)(this);
  52. }
  53. //# sourceMappingURL=windowCount.js.map