Socket
Book a DemoInstallSign in
Socket

promaphore

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promaphore

Promise Semaphore

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2.3K
80.84%
Maintainers
1
Weekly downloads
 
Created
Source

promaphore

Promise Semaphore

npm install promaphore

Usage

const Semaphore = require('promaphore')

const s = new Semaphore(2) // 2 is the max operation count

if (await s.wait()) { // wait for the to enter the block (only 2 can be in here at once)
  s.signal() // signal that you are exiting the block
}

If you want to await all pending operations do await s.flush() If you want to signal all pending waits do s.destroy()

License

MIT

FAQs

Package last updated on 21 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts