UNPKG

@mtdt.temp/browser-core

Version:
32 lines 856 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createBoundedBuffer = createBoundedBuffer; const arrayUtils_1 = require("./utils/arrayUtils"); const BUFFER_LIMIT = 500; /** * createBoundedBuffer creates a BoundedBuffer. * * @deprecated Use `BufferedObservable` instead. */ function createBoundedBuffer() { const buffer = []; const add = (callback) => { const length = buffer.push(callback); if (length > BUFFER_LIMIT) { buffer.splice(0, 1); } }; const remove = (callback) => { (0, arrayUtils_1.removeItem)(buffer, callback); }; const drain = (arg) => { buffer.forEach((callback) => callback(arg)); buffer.length = 0; }; return { add, remove, drain, }; } //# sourceMappingURL=boundedBuffer.js.map