Miss any of our Open RFC calls?Watch the recordings here! »

@da440dil/js-locker

0.2.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

3

Version

0.2.0

License

MIT

Unpacked Size

19.4 kB

Total Files

21

Last publish

Collaborators

  • avatar