ringbuf.js

ringbuf.js is a single-producer single-consumer wait-free ring buffer library written in JavaScript, that uses SharedArrayBuffers to allow non-blocking communication between the main thread of a web application, Web Workers, and an AudioWorkletGlobalScope.

After an initial phase of setup, it is possible to read and write from and to the ring buffer without causing any garbage collection or making any allocations, making it particularly suitable for high-performance communication in real-time audio processing scenario.

When not used in a real-time context, a slighly more user-friendly API can be used, at the expense of very minimal generation of garbage, that is often acceptable with current garbage collector implementations.

The source code of the library and a ready-to-use package are available at:
The generated documentation is available at /doc/.
The examples (generously commented) are deployed at https://ringbuf-js.netlify.app/, but cloning the repository and using the sample node.js server server.js available at the root of the repository and serving the public/ works just as well.
Two examples are avaible on this page: