A small library for waiting in JavaScript.
npm install @trenskow/semaphore@trenskow/semaphore
----
A small library for waiting in JavaScript.
Create a new semaphore like below.
```JavaScript
const Semaphore = require('@trenskow/semaphore');
const mySemaphore = new Semaphore();
``
To wait do as below.
``javascript``
await mySemaphore.wait();
To signal (from another place) that one of the waiters can continue, do as below.
``javascript``
mySemaphore.signal();
ā or to broadcast to all awaiters to conitnue.
``javascript``
mySemaphore.broadcast();
You can also reject all awaiters with an error.
``javascript```
mySemphore.reject(myError);
See license in LICENSE.