Skip to content

Releases: DevsDaddy/flash-buffer

Public Release (1.0.0)

08 Apr 23:58
93ea05a

Choose a tag to compare

A lightning-fast, zero-copy binary data manipulation library for TypeScript.

⚡ FlashBuffer provides a powerful and convenient API for reading from and writing to ArrayBuffer and SharedArrayBuffer. It eliminates manual offset tracking, automatically manages buffer growth, and is designed for maximum performance by avoiding unnecessary memory copying wherever possible.

The library includes a suite of advanced tools: from bit-level operations and VarInt encoding to declarative object serialization.


Flash Buffer NPM Flash Buffer - MIT opensource

🚀 Flash Buffer Features

  • Zero-Copy Operations: Reading bytes returns a direct Uint8Array view into the underlying buffer, not a copy.

Smart Memory Management:

  • Automatic Offset Tracking: The internal cursor advances automatically on reads and writes.
  • Dynamic Buffer Growth: Buffers expand automatically when needed. Choose from exact, powerOfTwo, or fixed growth strategies.
  • Efficient Buffer Pool (FlashBufferPool): Reuses buffers of similar sizes to reduce GC pressure.
  • Resizable ArrayBuffer: Leverages the native ArrayBuffer.prototype.resize() for high-performance memory management.

Cross-Platform:

  • SharedArrayBuffer Support: Enables safe and efficient zero-copy data sharing between threads (Web Workers, Node.js Worker Threads).
  • Works Everywhere: Runs seamlessly in modern browsers, Node.js, Deno, and Bun.

Advanced Data Formats:

  • VarInt (LEB128) with ZigZag Encoding: Efficient storage for variable-length integers, commonly used in Protocol Buffers.
  • Bit-Level Operations (BitBuffer): Read and write arbitrary numbers of bits (1-32) for flags, compressed data, and cryptography.
  • C-Strings (Null-Terminated Strings): Convenient handling of strings found in system APIs and network protocols.
  • Streaming I/O: Adapters for seamless integration with Web Streams API (FlashReadableStream / FlashWritableStream).

Schema-Based Serialization (experimental):

  • Declarative Schemas: Define binary structures using TypeScript decorators (@field).
  • Automatic (De)Serialization: The Schema class serializes and deserializes objects to and from binary buffers, eliminating manual errors.