A lightweight Promise-based mutex library (v1.1.0) that prevents concurrent execution of guarded code sections by queuing calls in order. Similar to node-synchronized but uses Promises natively and includes both TypeScript and Flow type definitions. It offers two main functions: synchd for one-off locking with a scope key, and synchdFn for creating wrapped functions that automatically serialize access. The library is minimal, has no dependencies, and follows a stable release cadence with simple, focused API.
npm install synchdNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using synchd() to guard a counter increment so three concurrent calls serialize correctly.
Use a shared object (e.g., const key = {};) or a Symbol as the scopeKey. Strings work only if compared by value (they are).Ensure fn is an async function or explicitly returns a Promise.
Change import to import { synchd } from 'synchd' or use require('synchd').synchd.Use const { synchd } = require('synchd'); or const synchd = require('synchd').synchd;Ensure the second argument is a function that returns a Promise, e.g., async () => { ... }.Run npm install synchd.