1.0.18 • Published 1 month ago

ringbud v1.0.18

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

RingBud: Zero-Dependency, High-Performance RingBuffer Library

version TypeScript license dependencies package size unpacked size

Table of Contents

Introduction

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.

Installation

To install RingBud, you can use npm:

npm install ringbud

Or yarn:

yarn add ringbud

Features

  • 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.

New: Clamping

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.

Usage

Basic Usage

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();

Advanced Features

Drain all available data from the buffer:

const allData = buffer.drain();

Memory Management

Memory Preallocation

RingBud preallocates memory based on your specified frame size, offering significant performance benefits by reducing the overhead of dynamic memory allocation.

Clamping for Large Buffers

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.

Extensibility with Typed Arrays

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.

Zero Dependencies

The library is self-contained and does not rely on any external dependencies, making it highly portable and easy to integrate.

Package Size

  • Package size: 8.2 kB
  • Unpacked size: 36.5 kB
  • Total files: 40

License

RingBud is licensed under the MIT License. For more details, see the LICENSE file.

1.0.18

1 month ago

1.0.17

1 month ago

1.0.16

1 month ago

1.0.14

1 month ago

1.0.13

1 month ago

1.0.12

1 month ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago