# bare-atomics

> Native synchronization primitives for JavaScript

Latest version **3.0.7** (published 2025-08-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install bare-atomics
pnpm add bare-atomics
yarn add bare-atomics
bun add bare-atomics
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.0.7 |
| Published | 2025-08-14 |
| First published | 2023-06-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 543.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Holepunch |
| Maintainers | mafintosh, kasperisager |

## Links

- npm: https://www.npmjs.com/package/bare-atomics
- Repository: https://github.com/holepunchto/bare-atomics
- Homepage: https://github.com/holepunchto/bare-atomics#readme
- Issues: https://github.com/holepunchto/bare-atomics/issues
- npm.io page: https://npm.io/package/bare-atomics

## Recent versions

- 3.0.7 (latest) — 2025-08-14
- 3.0.6 — 2024-12-11
- 3.0.5 — 2024-10-21
- 3.0.4 — 2024-09-13
- 3.0.3 — 2024-09-10
- 3.0.2 — 2024-09-02
- 3.0.1 — 2024-08-29
- 3.0.0 — 2024-04-05
- 2.0.4 — 2024-03-13
- 2.0.3 — 2024-02-13
- 2.0.2 — 2024-02-09
- 2.0.1 — 2024-02-02
- 2.0.0 — 2023-11-16
- 1.0.0 — 2023-06-09

## README

# bare-atomics

Native synchronization primitives for JavaScript.

```
npm i bare-atomics
```

## API

### Mutex

#### `const mutex = new Mutex([options])`

Options include:

```js
{
  recursive: false
}
```

#### `const mutex = Mutex.from(handle[, options])`

Options are the same as `new Mutex()`.

#### `mutex.handle`

A `SharedArrayBuffer` with the underlying mutex handle.

#### `mutex.held`

Whether or not the current thread currently holds the mutex.

#### `mutex.lock()`

#### `const success = mutex.tryLock()`

#### `mutex.unlock()`

#### `mutex.destroy()`

### Semaphore

#### `const semaphore = new Semaphore(value)`

#### `const semaphore = Semaphore.from(handle)`

#### `semaphore.handle`

A `SharedArrayBuffer` with the underlying semaphore handle.

#### `semaphore.wait()`

#### `const success = semaphore.tryWait()`

#### `semaphore.post()`

#### `semaphore.destroy()`

### Condition

#### `const condition = new Condition()`

#### `const condition = Condition.from(handle)`

#### `condition.handle`

A `SharedArrayBuffer` with the underlying condition handle.

#### `const success = condition.wait(mutex[, timeout])`

#### `condition.signal()`

#### `condition.broadcast()`

#### `condition.destroy()`

### Barrier

#### `const barrier = new Barrier(count)`

#### `const barrier = Barrier.from(handle)`

#### `barrier.handle`

A `SharedArrayBuffer` with the underlying barrier handle.

#### `const success = barrier.wait()`

#### `barrier.destroy()`

## License

Apache-2.0

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