38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
|
/** PURE_IMPORTS_START tslib,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */
|
||
|
import * as tslib_1 from "tslib";
|
||
|
import { OuterSubscriber } from '../OuterSubscriber';
|
||
|
import { subscribeToResult } from '../util/subscribeToResult';
|
||
|
export function buffer(closingNotifier) {
|
||
|
return function bufferOperatorFunction(source) {
|
||
|
return source.lift(new BufferOperator(closingNotifier));
|
||
|
};
|
||
|
}
|
||
|
var BufferOperator = /*@__PURE__*/ (function () {
|
||
|
function BufferOperator(closingNotifier) {
|
||
|
this.closingNotifier = closingNotifier;
|
||
|
}
|
||
|
BufferOperator.prototype.call = function (subscriber, source) {
|
||
|
return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
|
||
|
};
|
||
|
return BufferOperator;
|
||
|
}());
|
||
|
var BufferSubscriber = /*@__PURE__*/ (function (_super) {
|
||
|
tslib_1.__extends(BufferSubscriber, _super);
|
||
|
function BufferSubscriber(destination, closingNotifier) {
|
||
|
var _this = _super.call(this, destination) || this;
|
||
|
_this.buffer = [];
|
||
|
_this.add(subscribeToResult(_this, closingNotifier));
|
||
|
return _this;
|
||
|
}
|
||
|
BufferSubscriber.prototype._next = function (value) {
|
||
|
this.buffer.push(value);
|
||
|
};
|
||
|
BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
|
||
|
var buffer = this.buffer;
|
||
|
this.buffer = [];
|
||
|
this.destination.next(buffer);
|
||
|
};
|
||
|
return BufferSubscriber;
|
||
|
}(OuterSubscriber));
|
||
|
//# sourceMappingURL=buffer.js.map
|