# @matrixai/async-locks

> Asynchronous locking utilities

Latest version **5.0.2** (published 2025-02-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @matrixai/async-locks
pnpm add @matrixai/async-locks
yarn add @matrixai/async-locks
bun add @matrixai/async-locks
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.2 |
| Published | 2025-02-04 |
| First published | 2022-03-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 4 |
| Unpacked size | 133.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Roger Qiu |
| Maintainers | brianbotha74, cmcdragonkai, matrixai-bot |

## Links

- npm: https://www.npmjs.com/package/@matrixai/async-locks
- Repository: https://github.com/MatrixAI/js-async-locks
- Homepage: https://github.com/MatrixAI/js-async-locks#readme
- Issues: https://github.com/MatrixAI/js-async-locks/issues
- npm.io page: https://npm.io/package/@matrixai/async-locks

## Dependencies (4)

- [@matrixai/timer](https://npm.io/package/@matrixai/timer.md) ^2.0.0
- [@matrixai/errors](https://npm.io/package/@matrixai/errors.md) ^2.0.1
- [@matrixai/resources](https://npm.io/package/@matrixai/resources.md) ^2.0.0
- [@matrixai/async-cancellable](https://npm.io/package/@matrixai/async-cancellable.md) ^2.0.0

## Recent versions

- 5.0.2 (latest) — 2025-02-04
- 5.0.1 — 2023-08-13
- 5.0.0 — 2023-08-13
- 4.0.0 — 2023-06-15
- 3.2.0 — 2022-09-16
- 3.1.2 — 2022-07-25
- 3.1.1 — 2022-07-14
- 3.1.0 — 2022-07-14
- 3.0.0 — 2022-06-30
- 2.3.1 — 2022-06-22
- 2.3.0 — 2022-06-21
- 2.2.5 — 2022-06-01
- 2.2.4 — 2022-05-11
- 2.2.3 — 2022-05-11
- 2.2.2 — 2022-05-10
- … 6 more at https://npm.io/package/@matrixai/async-locks/versions

## README

# js-async-locks

Asynchronous lock utilities.

JavaScript exposes the ability to create interleaved execution of asynchronous
operations. When this is done with shared state between asynchronous
overlapping functions that perform partial state transitions, this can lead to
race conditions or data corruption and clobbering, or just invalid pre-condition
or post-condition behaviour.

This library provides multiple synchronization constructs that allow one to
precisely control concurrent operations. These constructs are intended for
pessimistic concurrency control. If you can prefer to use optimistic concurrency
control mechanisms. But that is outside the scope of this library. In many cases
you cannot use optimistic methods, and thus you need this library.

## Installation

```sh
npm install --save @matrixai/async-locks
```

## Development

Run `nix develop`, and once you're inside, you can use:

```sh
# install (or reinstall packages from package.json)
npm install
# build the dist
npm run build
# run the repl (this allows you to import from ./src)
npm run tsx
# run the tests
npm run test
# lint the source code
npm run lint
# automatically fix the source
npm run lintfix
```

### Docs Generation

```sh
npm run docs
```

See the docs at: https://matrixai.github.io/js-async-locks/

### Publishing

Publishing is handled automatically by the staging pipeline.

Prerelease:

```sh
# npm login
npm version prepatch --preid alpha # premajor/preminor/prepatch
git push --follow-tags
```

Release:

```sh
# npm login
npm version patch # major/minor/patch
git push --follow-tags
```

Manually:

```sh
# npm login
npm version patch # major/minor/patch
npm run build
npm publish --access public
git push
git push --tags
```

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