quantix
v1.0.1
Published
Quantix — Ultra-fast hybrid circular-buffer, double-ended queue and ring-buffer in TypeScript. Pre-allocated memory, zero-copy O(1) slicing, TypedArray support, and V8-optimized iterators.
Maintainers
Readme
Quantix
Quantix is an ultra-fast, hybrid double-ended queue, circular buffer, and ring-buffer library built for TypeScript/JavaScript and powered by an optional, precompiled Rust Native Layer with CPU-level SIMD acceleration.
By combining V8-optimized contiguous memory layouts in TypeScript with raw mathematical speed in Rust, Quantix offers unmatched performance for both generic object queues and heavy numerical batch streams.
Important: Rust Native Acceleration Quantix embeds a pre-compiled Rust Native Layer via Node-API. Standard numerical and vector operations cross the JS-Rust boundary once per batch, offering up to 20x faster sorting and SIMD acceleration on compatible hardware. Best of all, no local Rust toolchain or build setup is required by end-users.
Why Quantix?
- Hybrid Architecture: Pure TypeScript for high-speed JS object handling, with transparent fallback if Rust binaries are not available.
- Rust Native Layer (
QuantixBuffer): Accelerates heavy numerical data with SIMD vectorization (AVX/SSE) and native Rustpdqsort. - 100% Memory Efficient: Uses an explicit size counter allowing all $N$ slots of the array to be populated (unlike competitors who waste space).
- Zero-Copy Slices (
.sliceView()): Extract sub-ranges of a deque in O(1) time — up to 38,000× faster than copying elements. - Bitwise Masking: Fast random access in O(1) via cached register variables and bitwise indexing
(head + i) & mask.
Performance at a Glance 🔥🚀
Node.js v24.11.1 · Median of 5 runs · Clean GC-isolated environment
Standard Workloads (10M Operations)
- FIFO Queue (Push & Shift): Quantix is 6.1% faster than
denqueand 12.9% faster thanjs-sdsl. - Stack Cycle (Push & Pop): Quantix is 25.1% faster than
denqueand 30.6% faster thanjs-sdsl. - Random Indexing (
get(i)): Quantix is 58.8% faster thandenqueand 76.7% faster thanjs-sdsl. - Zero-Copy Slicing (
sliceView): Quantix is 19,483× faster thandenqueand 38,835× faster thanjs-sdsl.
Extreme Big-Data Workloads (5M–10M Operations)
- High Memory/GC Pressure: Quantix is 1.47% faster than
denqueand 7.88% faster thanjs-sdsl. - Extreme Mixed Workloads: Quantix is 9.1% faster than
denqueand 2.8% faster thanjs-sdsl.
Installation
Install Quantix using your preferred package manager:
npm
npm install quantixyarn
yarn add quantixpnpm
pnpm add quantixbun
bun add quantixNote: The Rust binary comes pre-compiled for major platforms (Windows, macOS, Linux). End-users do not need to have Rust installed on their machine to get maximum native performance.
Quick Start
1. High-Speed Generic Queue (Pure TypeScript)
import { QuantixDeque } from 'quantix';
// Create a growable deque
const queue = new QuantixDeque<string>({ capacity: 1024 });
// Add items
queue.push("User A");
queue.push("User B");
queue.unshift("Admin"); // Prepend to front
// Fast O(1) random reads
console.log(queue.get(0)); // "Admin"
console.log(queue.size); // 3
// Draining items
console.log(queue.shift()); // "Admin"
console.log(queue.pop()); // "User B"2. Rust-Powered Numeric Buffer (SIMD & Batch Operations)
import { QuantixBuffer } from 'quantix';
// Initialize pre-allocated numeric buffer
const buffer = new QuantixBuffer(1_000_000);
// Zero-copy batch insert (crosses JS-Rust boundary exactly once)
const chunk = new Float64Array([10.5, 20.0, 30.5, 40.0]);
buffer.pushBatch(chunk);
// Scale all elements by 2.5 and add 10 in-place (SIMD in Rust)
buffer.scale(2.5);
buffer.offset(10.0);
// Sort ascending using native Rust pdqsort (19× faster than V8 sort)
buffer.sortAsc();
console.log(buffer.sum()); // Native aggregate sumLearn More
Check out the detailed documentation:
- API Reference — Complete parameter specifications and classes.
- Architecture & Optimizations — Deep-dive on packed arrays, register caching, and NAPI bridging.
- Full Benchmark Report — Standard and extreme performance results.
Contact
Feel free to reach out to the developer at [email protected] :)
