
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@toolbuilder/dynamic-ring-buffer
Advanced tools
A ring buffer that manages memory in chunks to support large capacity for data bursts with low overhead when small.
DynamicRingBuffer implements classic fixed length ring buffer, or circular queue. Memory is dynamically allocated and deallocated in chunks as the buffer grows and shrinks. This allows the buffer to have a large capacity to handle data bursts, while minimizing memory use during normal operation.
When the buffer length reaches capacity, the oldest values are quietly thrown away. The methods match the Array signature for push, pop, unshift, and shift. For buffer operation either use push/shift together, or unshift/pop together.
DynamicRingBuffer
is a minimal implementation developed for use with Await-For-It iterable queues.
There are two related buffers:
There are lots of ring buffer implementations on NPM. This implementation:
Array
to convert a buffer to a ring buffer.exports
and module
properties in package.json
pointing to the ES source for bundlers.Symbol.iterator
generator.npm install --save @toolbuilder/dynamic-ring-buffer
The API documentation is here. This is a quick example to get you started.
import { DynamicRingBuffer } from '@toolbuilder/dynamic-ring-buffer'
const log = console.log
const ringBuffer = new DynamicRingBuffer(100, 10000) // max length 10000 in chunks of 100
log(ringBuffer.length) // prints 0
['A', 'B', 'C'].forEach(x => ringBuffer.push(x))
log(ringBuffer.length) // prints 3
log(ringBuffer.front()) // prints 'A'
log(ringBuffer.back()) // prints 'C'
log(ringBuffer.shift()) // pulls 'A' off front and prints 'A'
log(ringBuffer.length) // prints 2
log([...ringBuffer]) // prints ['B', 'C']
log(ringBuffer.length) // prints 2
There are lots of alternatives on npm.
Contributions are welcome. Please create a pull request.
pnpm test
npm install -g pnpm
pnpm install
pnpm test
to run unit testspnpm run check:packfile
to test the pack file against Node ES and CommonJS projects, as well as Electron.pnpm run check
to validate the package is ready for commitThis project uses Github issues.
MIT
FAQs
A ring buffer that manages memory in chunks to support large capacity for data bursts with low overhead when small.
We found that @toolbuilder/dynamic-ring-buffer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.