Detalhes do pacote

@toolbuilder/semaphore

toolbuilder1.2kMIT0.1.7

Basic semaphore and mutex with both sync and async acquire methods.

semaphore, mutex, acquire, async

readme (leia-me)

Semaphore and Mutex

This library provides Semaphore and Mutex implementations. You can acquire a lock with either async or sync methods.

Installation

npm install @toolbuilder/semaphore

Use

The API documentation is here

import { Mutex } from '@toolbuilder/semaphore'

const mutex = new Mutex()
const release = await mutex.acquire()
release() // to release mutex
import { Mutex, Semaphore } from '@toolbuilder/semaphore'

const semaphore = new Semaphore(5) // max locks that can be acquired
await semaphore.acquire()
semaphore.release() // to release lock

Contributing

Contributions are welcome. Please create a pull request.

  • I use pnpm instead of npm.
  • Package verification requires pnpm to be installed globally.
    • npm install -g pnpm
    • pnpm install
    • pnpm test to run unit tests
    • pnpm run check:packfile to test the pack file against Node ES and CommonJS projects, as well as Electron.
    • pnpm run check to validate the package is ready for commit

Issues

This project uses Github issues.

License

MIT

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file. See commit-and-tag-version for commit guidelines.

0.1.7 (2024-11-08)

0.1.6 (2023-08-18)

0.1.5 (2022-02-09)

0.1.4 (2021-07-21)

Features

  • dual package: ES module with CommonJS support (50c8d7b)

0.1.3 (2020-07-20)

0.1.2 (2020-06-25)

Bug Fixes

0.1.1 (2020-06-25)