1.0.0 • Published 6 years ago
p-semaphore v1.0.0
p-semaphore
A simple async/await semaphore implementation
installation
npm install p-semaphore
usage
const semaphore = require('./p-semaphore.js')
const { V, P } = semaphore(1) // initial value (defaults to 1)await P() // will down/wait/decrement, always has to be awaited
V() // will up/signal/increase, syncronuse callFor convenience semaphore() also returns signal/wait as well as increment/decrement:
const { signal, wait } = semaphore(1)
const { increment, decrement } = semaphore(1)1.0.0
6 years ago