843a36b9b3389420c81fc053c00744da3bdd4ced51bf3dcd5bcf96a8bd82cd4cd843321d8e574a9121a9850f908d37d8ad05a2b6aeb68badae7423ab22f47b 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { OperatorFunction } from '../types';
  2. /**
  3. * Buffers the source Observable values until the size hits the maximum
  4. * `bufferSize` given.
  5. *
  6. * <span class="informal">Collects values from the past as an array, and emits
  7. * that array only when its size reaches `bufferSize`.</span>
  8. *
  9. * ![](bufferCount.png)
  10. *
  11. * Buffers a number of values from the source Observable by `bufferSize` then
  12. * emits the buffer and clears it, and starts a new buffer each
  13. * `startBufferEvery` values. If `startBufferEvery` is not provided or is
  14. * `null`, then new buffers are started immediately at the start of the source
  15. * and when each buffer closes and is emitted.
  16. *
  17. * ## Examples
  18. *
  19. * Emit the last two click events as an array
  20. *
  21. * ```ts
  22. * import { fromEvent, bufferCount } from 'rxjs';
  23. *
  24. * const clicks = fromEvent(document, 'click');
  25. * const buffered = clicks.pipe(bufferCount(2));
  26. * buffered.subscribe(x => console.log(x));
  27. * ```
  28. *
  29. * On every click, emit the last two click events as an array
  30. *
  31. * ```ts
  32. * import { fromEvent, bufferCount } from 'rxjs';
  33. *
  34. * const clicks = fromEvent(document, 'click');
  35. * const buffered = clicks.pipe(bufferCount(2, 1));
  36. * buffered.subscribe(x => console.log(x));
  37. * ```
  38. *
  39. * @see {@link buffer}
  40. * @see {@link bufferTime}
  41. * @see {@link bufferToggle}
  42. * @see {@link bufferWhen}
  43. * @see {@link pairwise}
  44. * @see {@link windowCount}
  45. *
  46. * @param bufferSize The maximum size of the buffer emitted.
  47. * @param startBufferEvery Interval at which to start a new buffer.
  48. * For example if `startBufferEvery` is `2`, then a new buffer will be started
  49. * on every other value from the source. A new buffer is started at the
  50. * beginning of the source by default.
  51. * @return A function that returns an Observable of arrays of buffered values.
  52. */
  53. export declare function bufferCount<T>(bufferSize: number, startBufferEvery?: number | null): OperatorFunction<T, T[]>;
  54. //# sourceMappingURL=bufferCount.d.ts.map