Socket
Book a DemoInstallSign in
Socket

concurrent-lock

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concurrent-lock

promise based concurrent implementation.

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

concurrent-lock

Promise based lock object supporting simultaneous access limit.

Install

npm install concurrent-lock

Usage

Create lock object with concurrent limit.

import Lock from 'concurrent-lock'

// concurrent access limit = 1
const simultaneous_limit = 2
const lock = new Lock(simultaneous_limit)

async somefunc() {
  await lock.lock()
  // ...some async proc...
  lock.unlock()

  // you can set timeout argument as millisec
  // Timeout error will be thrown if lock couldn't acquire within specified timeout millisec.
  await lock.lock(3000)
  // ...some async proc...
  lock.unlock()
}

Author

Yusuke Shibata

Licence

MIT

Keywords

concurrent

FAQs

Package last updated on 18 Mar 2019

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