# minimum-lock

> The only minimum async lock you need.

Latest version **1.2.0** (published 2026-06-20) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install minimum-lock
pnpm add minimum-lock
yarn add minimum-lock
bun add minimum-lock
```

## Health

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

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2026-06-20 |
| First published | 2023-12-04 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Hai Binh Nguyen |
| Maintainers | hbinhng |

## Links

- npm: https://www.npmjs.com/package/minimum-lock
- Repository: https://github.com/hbinhng/minimum-lock
- Homepage: https://github.com/hbinhng/minimum-lock#readme
- Issues: https://github.com/hbinhng/minimum-lock/issues
- npm.io page: https://npm.io/package/minimum-lock

## Recent versions

- 1.2.0 (latest) — 2026-06-20
- 1.1.0 — 2025-09-24
- 1.0.2 — 2025-06-22
- 1.0.1 — 2023-12-06
- 1.0.0 — 2023-12-04

## README

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Coverage Status](https://coveralls.io/repos/github/hbinhng/minimum-lock/badge.svg?branch=main)](https://coveralls.io/repos/github/hbinhng/minimum-lock/badge.svg?branch=main)

# Minimum lock
This package provides a bare minimum tool for "locking" resources.

# How to use it?

## Installation
You can install the library into your project via npm:

```sh
npm install minimum-lock
```
This package does not have any dependencies.

## Usage
Again, this tool is bare minimum, it does not provide any fancy interface, just a class to create an object which can be locked and released.

```ts
import { Lock } from 'minimum-lock';

async function doSomethingWithLock(lock) {
  const release = await lock.acquire();
  
  doSomethingMustBeSequential();
  
  release();
}

async function doSomething() {
  ...
  
  const lock = new Lock();
  
  doSomethingWithLock(lock);
  doSomethingWithLock(lock);
}
```

⚠️ The `acquire` method returns a `release` callback, if you forget to call this `release` callback, the lock is locked forever.

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