# @trenskow/semaphore

> A small library for waiting in JavaScript.

Latest version **0.2.27** (published 2026-09-16) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install @trenskow/semaphore
pnpm add @trenskow/semaphore
yarn add @trenskow/semaphore
bun add @trenskow/semaphore
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.27 |
| Published | 2026-09-16 |
| First published | 2021-08-07 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kristian Trenskow |
| Maintainers | trenskow |
| Keywords | semaphore, wait, promises |

## Links

- npm: https://www.npmjs.com/package/@trenskow/semaphore
- Repository: https://github.com/trenskow/semaphore
- Homepage: https://github.com/trenskow/semaphore#readme
- Issues: https://github.com/trenskow/semaphore/issues
- npm.io page: https://npm.io/package/@trenskow/semaphore

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.2.27 (latest) — 2026-09-16
- 0.2.26 — 2026-08-03
- 0.2.25 — 2026-07-27
- 0.2.24 — 2026-07-13
- 0.2.23 — 2026-07-02
- 0.2.22 — 2026-06-25
- 0.2.21 — 2026-06-08
- 0.2.20 — 2026-05-19
- 0.2.19 — 2026-05-04
- 0.2.18 — 2026-03-28
- 0.2.17 — 2026-02-14
- 0.2.16 — 2026-02-01
- 0.2.15 — 2026-01-06
- 0.2.14 — 2025-12-17
- 0.2.13 — 2025-12-01
- … 32 more at https://npm.io/package/@trenskow/semaphore/versions

## README

@trenskow/semaphore
----

A small library for waiting in JavaScript.

# Usage

Create a new semaphore like below.

````JavaScript
const Semaphore = require('@trenskow/semaphore');

const mySemaphore = new Semaphore();
````

## Waiting

To wait do as below.

````javascript
await mySemaphore.wait();
````

## Signalling and broadcasting

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();
````

## Errors

You can also reject all awaiters with an error.

````javascript
mySemphore.reject(myError);
````

# LICENSE

See license in LICENSE.

---
_Source: https://npm.io/package/@trenskow/semaphore · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
