buffer.js 1.0 KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.buffer = void 0;
  4. var lift_1 = require("../util/lift");
  5. var noop_1 = require("../util/noop");
  6. var OperatorSubscriber_1 = require("./OperatorSubscriber");
  7. var innerFrom_1 = require("../observable/innerFrom");
  8. function buffer(closingNotifier) {
  9. return lift_1.operate(function (source, subscriber) {
  10. var currentBuffer = [];
  11. source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) { return currentBuffer.push(value); }, function () {
  12. subscriber.next(currentBuffer);
  13. subscriber.complete();
  14. }));
  15. innerFrom_1.innerFrom(closingNotifier).subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function () {
  16. var b = currentBuffer;
  17. currentBuffer = [];
  18. subscriber.next(b);
  19. }, noop_1.noop));
  20. return function () {
  21. currentBuffer = null;
  22. };
  23. });
  24. }
  25. exports.buffer = buffer;
  26. //# sourceMappingURL=buffer.js.map