hugoWebsite/node_modules/rxjs/dist/esm/internal/operators/buffer.js

21 lines
772 B
JavaScript
Raw Normal View History

2022-10-29 00:20:35 +02:00
import { operate } from '../util/lift';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function buffer(closingNotifier) {
return operate((source, subscriber) => {
let currentBuffer = [];
source.subscribe(createOperatorSubscriber(subscriber, (value) => currentBuffer.push(value), () => {
subscriber.next(currentBuffer);
subscriber.complete();
}));
closingNotifier.subscribe(createOperatorSubscriber(subscriber, () => {
const b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
}, noop));
return () => {
currentBuffer = null;
};
});
}
//# sourceMappingURL=buffer.js.map