Package Exports
- cirbuf
- cirbuf/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cirbuf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cirbuf
A tiny and fast circular buffer
- Minimal API
- Tiny size fit for the browser
- Fast
Install
npm install --save cirbuf
Usage
// Import CircularBuffer
import { CircularBuffer } from "cirbuf"
// Create a buffer with a capacity of 10,000
const buffer = new CircularBuffer(10_000)
// Push 100,000 items
for (let i = 0; i < 100_000; i++) {
buffer.push(i)
}
// Get the last 10,000 items as an array
const result = buffer.toArray()
// Note: `toArray` does not drain the buffer.