Node.js implementation of the Web Locks API that provides mutex and semaphore primitives for coordinating access to shared resources across worker threads. v0.0.9 (stable) uses worker_threads, Atomics, and SharedArrayBuffer for multi-threaded locking, with a fallback to single-threaded async locks. Supports a single unified API for both single-threaded and multi-threaded environments. Part of the Metarhia stack, targeting eventual inclusion in Node.js core. Minimal dependencies, MIT licensed.
npm install web-locksNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: acquire a named lock, perform async work inside, and return a value. Shows promise-based API.
Use Node.js >=11. Ensure your Node.js build supports SharedArrayBuffer (e.g., not disabled by security policies).
Always use async (lock) => { ... } or return a promise from the callback.Check the documentation for differences. Use the `locks` manager from this package, not the global `navigator`.
Update to ESM imports: `import { locks } from 'web-locks'`.Use `import { locks } from 'web-locks'` (not `import Lock from 'web-locks'`).Use Node.js >=11 or run with `--enable-sharedarraybuffer` flag if needed.
Pass an async function: `await locks.request('name', async (lock) => { ... })`.Upgrade to Node.js >=11 or use a polyfill if absolutely necessary.
No dependency data recorded yet.