@timeseries/window-query
v0.1.1
Published
Time-series window queries using binary search and no-alloc patterns
Downloads
74
Maintainers
Readme
@timeseries/ts-window-query
WebAssembly-powered time-series window queries using binary search.
Installation
npm install @timeseries/ts-window-queryUsage
import init, { windowIndices, lowerBound, upperBound } from "@timeseries/ts-window-query";
await init();
const timestamps = new Float64Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
// Get index range [start, end) for window [2.0, 7.0]
const [start, end] = windowIndices(timestamps, 2.0, 7.0);
// Or use individual binary search functions
const lb = lowerBound(timestamps, 2.5); // first index >= 2.5
const ub = upperBound(timestamps, 6.5); // first index > 6.5Benchmarks
Node.js WASM benchmarks (npm run bench):
| Function | n=1K | n=100K | n=1M | |----------|------|--------|------| | windowIndices | 1.9µs | 23.1µs | 632µs | | lowerBound | 1.5µs | 22.6µs | 619µs | | upperBound | 1.5µs | 22.6µs | 622µs |
Note: WASM numbers include JS↔WASM boundary overhead (data copying).
License
MIT OR Apache-2.0
