npm

Need private packages and team management tools?Check out npm Orgs. »

@da440dil/js-locker

0.1.0 • Public • Published

js-locker

Build Status Coverage Status

Distributed locking with pluggable storage for storing locks state.

Basic usage

// Create new Locker
const locker = new Locker({ ttl: 100 })
try {
  // Create and apply lock
  const lock = await locker.lock('key')
  // Do smth  
  await lock.unlock() // Release lock
} catch (err) {
  if (err instanceof TTLError) {
    // Use err.TTL() if need
  } else {
    // Handle err
  }
}

Example usage

install

npm i @da440dil/js-locker

Downloadsweekly downloads

14

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability