Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

buffer.js 974B

123456789101112131415161718192021222324252627282930
  1. import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
  2. export function buffer(closingNotifier) {
  3. return function bufferOperatorFunction(source) {
  4. return source.lift(new BufferOperator(closingNotifier));
  5. };
  6. }
  7. class BufferOperator {
  8. constructor(closingNotifier) {
  9. this.closingNotifier = closingNotifier;
  10. }
  11. call(subscriber, source) {
  12. return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
  13. }
  14. }
  15. class BufferSubscriber extends SimpleOuterSubscriber {
  16. constructor(destination, closingNotifier) {
  17. super(destination);
  18. this.buffer = [];
  19. this.add(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(this)));
  20. }
  21. _next(value) {
  22. this.buffer.push(value);
  23. }
  24. notifyNext() {
  25. const buffer = this.buffer;
  26. this.buffer = [];
  27. this.destination.next(buffer);
  28. }
  29. }
  30. //# sourceMappingURL=buffer.js.map