https://github.com/jagi/mutex
Simple TypeScript mutex implementation
https://github.com/jagi/mutex
Last synced: 10 months ago
JSON representation
Simple TypeScript mutex implementation
- Host: GitHub
- URL: https://github.com/jagi/mutex
- Owner: jagi
- Created: 2019-10-27T22:08:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:34:28.000Z (over 3 years ago)
- Last Synced: 2025-09-27T11:15:47.798Z (10 months ago)
- Language: TypeScript
- Size: 250 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @jagi/mutex
Simple TypeScript mutex implementation
## Installation
```bash
npm install @jagi/mutex -S
```
or
```bash
yarn add @jagi/mutex
```
## Usage
```ts
import Mutex from "@jagi/mutex";
const mutext = new Mutex();
const asyncActionResult = await mutex.run(async () => {
// Running asynchronous action.
return await asyncAction();
});
mutex.run(async () => {
// This action will wait for the first one to finish.
await anotherAsyncAction();
});
```