Licence
BSD-2-Clause
Version
0.2.27
Deps
0
Vulns
0
Weekly
0
@trenskow/semaphore
A small library for waiting in JavaScript.
Usage
Create a new semaphore like below.
const Semaphore = require('@trenskow/semaphore');
const mySemaphore = new Semaphore();
Waiting
To wait do as below.
await mySemaphore.wait();
Signalling and broadcasting
To signal (from another place) that one of the waiters can continue, do as below.
mySemaphore.signal();
– or to broadcast to all awaiters to conitnue.
mySemaphore.broadcast();
Errors
You can also reject all awaiters with an error.
mySemphore.reject(myError);
LICENSE
See license in LICENSE.