Iterflow: Composable Streaming Statistics for JavaScript
Description
We present iterflow, a zero-dependency JavaScript library that integrates online statistical algorithms into lazy iterator pipelines. ES2025 Iterator Helpers provide lazy transforms but no statistics; libraries like @stdlib/stats/incr provide streaming accumulators but not as composable pipeline stages. iterflow bridges this gap: Welford's variance, EWMA, streaming Pearson correlation, z-score anomaly detection, and monotonic deque windowed extrema are implemented as chainable pipeline stages that compose with map, filter, window, and take while preserving lazy evaluation and O(1) memory per stage. Benchmarks on synthetic workloads show a 296x throughput improvement over eager array pipelines with early termination at N=10^6, and a 780x improvement for streaming versus recomputed correlation at N=10^4. For standalone single-statistic computation, the generator-based design incurs 3-5x overhead relative to hand-written loops.
Files
Iterflow2026_v1-r2.pdf
Files
(352.4 kB)
| Name | Size | Download all |
|---|---|---|
|
md5:84980167421ac48229cf316196aaaae2
|
352.4 kB | Preview Download |
Additional details
Software
- Repository URL
- https://github.com/mathscapes/iterflow
- Programming language
- JavaScript , TypeScript
- Development Status
- Active
References
- Tony F. Chan, Gene H. Golub, and Randall J. LeVeque. Updating formulae and a pairwise algorithm for computing sample variances. In COMPSTAT 1982: Proceedings in Computational Statistics, pages 30–41. Physica-Verlag, 1982.
- Nicholas J. Higham. Accuracy and Stability of Numerical Algorithms. SIAM, 2nd edition, 2002.
- C. A. R. Hoare. Algorithm 65: Find. Communications of the ACM, 4(7):321–322, 1961.
- J. Stuart Hunter. The exponentially weighted moving average. Journal of Quality Technology, 18(4):203–210, 1986.
- Daniel Lemire. Streaming maximum-minimum filter using no more than three comparisons per element. Nordic Journal of Computing, 13(4):328–339, 2006
- Tom MacWright. simple-statistics: Statistical methods in readable JavaScript. https: //github.com/simple-statistics/simple-statistics, 2024.
- RxJS Contributors. RxJS: Reactive extensions library for JavaScript. https://rxjs.dev, 2024.
- stdlib Authors. stdlib: A standard library for JavaScript and Node.js. https://github. com/stdlib-js/stdlib, 2024.
- TC39. ECMAScript iterator helpers proposal. https://github.com/tc39/ proposal-iterator-helpers, 2025. Stage 4, ES2025.
- B. P. Welford. Note on a method for calculating corrected sums of squares and products. Technometrics, 4(3):419–420, 1962.