- Introduction
- Installation
- Features
- Usage
- Memory Management
- Extensibility with Typed Arrays
- Zero Dependencies
- Package Size
- License
RingBud is a high-performance, TypeScript-based RingBuffer library engineered for efficient data storage and retrieval. The API is designed to be both user-friendly and versatile, allowing fine-grained control over buffer operations.
To install RingBud, you can use npm:
npm install ringbud
Or yarn:
yarn add ringbud
- Type-Safe: Fully written in TypeScript for robust type safety.
- Memory-Efficient: Features like preallocation and clamping optimize memory usage.
- Customizable: Adjustable frame size to fit diverse application requirements.
- High-Speed Read/Write: Employs optimized algorithms for rapid data access.
- Zero Dependencies: Completely standalone with no external dependencies.
- Lightweight: A minuscule package footprint for efficient deployment.
The library now includes a clamping feature, enabled by default. When clamping is enabled, the remaining bytes in the buffer are moved to the beginning after each read operation. This avoids the need for resizing the buffer for new data, thereby optimizing memory usage. The trade-off is that the buffer is copied upon each read operation.
Here's a quick example to get started:
import { RingBufferF32 } from "ringbud";
const frameSize = 128;
const buffer = new RingBufferF32(frameSize);
// Write data into the buffer
const data = new Float32Array([1.1, 2.2, 3.3]);
buffer.write(data);
// Read data from the buffer
const readData = buffer.read();
Drain all available data from the buffer:
const allData = buffer.drain();
RingBud preallocates memory based on your specified frame size, offering significant performance benefits by reducing the overhead of dynamic memory allocation.
With the new clamping feature, RingBud can handle large buffers efficiently without resizing the memory, albeit at the cost of copying the buffer during each read operation.
RingBud supports a broad spectrum of Typed Arrays, including Float32Array, Int16Array, Int32Array, Uint8Array, Uint16Array, Uint32Array, and Uint8ClampedArray, providing unparalleled flexibility for different data storage needs.
The library is self-contained and does not rely on any external dependencies, making it highly portable and easy to integrate.
- Package size: 8.2 kB
- Unpacked size: 36.5 kB
- Total files: 40
RingBud is licensed under the MIT License. For more details, see the LICENSE file.