Front end of the Slack clone application.

bufferCount.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. var bufferCount_1 = require('../operators/bufferCount');
  3. /**
  4. * Buffers the source Observable values until the size hits the maximum
  5. * `bufferSize` given.
  6. *
  7. * <span class="informal">Collects values from the past as an array, and emits
  8. * that array only when its size reaches `bufferSize`.</span>
  9. *
  10. * <img src="./img/bufferCount.png" width="100%">
  11. *
  12. * Buffers a number of values from the source Observable by `bufferSize` then
  13. * emits the buffer and clears it, and starts a new buffer each
  14. * `startBufferEvery` values. If `startBufferEvery` is not provided or is
  15. * `null`, then new buffers are started immediately at the start of the source
  16. * and when each buffer closes and is emitted.
  17. *
  18. * @example <caption>Emit the last two click events as an array</caption>
  19. * var clicks = Rx.Observable.fromEvent(document, 'click');
  20. * var buffered = clicks.bufferCount(2);
  21. * buffered.subscribe(x => console.log(x));
  22. *
  23. * @example <caption>On every click, emit the last two click events as an array</caption>
  24. * var clicks = Rx.Observable.fromEvent(document, 'click');
  25. * var buffered = clicks.bufferCount(2, 1);
  26. * buffered.subscribe(x => console.log(x));
  27. *
  28. * @see {@link buffer}
  29. * @see {@link bufferTime}
  30. * @see {@link bufferToggle}
  31. * @see {@link bufferWhen}
  32. * @see {@link pairwise}
  33. * @see {@link windowCount}
  34. *
  35. * @param {number} bufferSize The maximum size of the buffer emitted.
  36. * @param {number} [startBufferEvery] Interval at which to start a new buffer.
  37. * For example if `startBufferEvery` is `2`, then a new buffer will be started
  38. * on every other value from the source. A new buffer is started at the
  39. * beginning of the source by default.
  40. * @return {Observable<T[]>} An Observable of arrays of buffered values.
  41. * @method bufferCount
  42. * @owner Observable
  43. */
  44. function bufferCount(bufferSize, startBufferEvery) {
  45. if (startBufferEvery === void 0) { startBufferEvery = null; }
  46. return bufferCount_1.bufferCount(bufferSize, startBufferEvery)(this);
  47. }
  48. exports.bufferCount = bufferCount;
  49. //# sourceMappingURL=bufferCount.js.map