0.1.7 • Published 12 months ago
@toolbuilder/semaphore v0.1.7
Semaphore and Mutex
This library provides Semaphore and Mutex implementations. You can acquire a lock with either async or sync methods.
Installation
npm install @toolbuilder/semaphoreUse
The API documentation is here
import { Mutex } from '@toolbuilder/semaphore'
const mutex = new Mutex()
const release = await mutex.acquire()
release() // to release muteximport { Mutex, Semaphore } from '@toolbuilder/semaphore'
const semaphore = new Semaphore(5) // max locks that can be acquired
await semaphore.acquire()
semaphore.release() // to release lockContributing
Contributions are welcome. Please create a pull request.
- I use pnpm instead of npm.
- Package verification requires pnpm to be installed globally.
npm install -g pnpmpnpm installpnpm testto run unit testspnpm run check:packfileto test the pack file against Node ES and CommonJS projects, as well as Electron.pnpm run checkto validate the package is ready for commit
Issues
This project uses Github issues.
License
MIT