git ssb

0+

wanderer🌟 / lockmap



Tree:
πŸ“„.travis.yml
πŸ“„LICENSE
πŸ“„README.md
πŸ“„index.js
πŸ“„package.json
πŸ“tests
README.md

SYNOPSIS

NPM Package
Build Status
Coverage Status

js-standard-style

Creates a map of locks to ids that can be used as a semaphore

INSTALL

npm install <name>

USAGE

const LockMap = require('lockmap')

const lockmap = new LockMap()
const id = 'test'

// set a lock for an id
const unlock = lockmap.lock(id)

setTimeout(() => {
  // do some async work
  console.log('here first!')
  unlock()
}, 300)

// wait until the lock resolves
await lockmap.getLock(id)
console.log('here now!')

API

getLock

index.js:29-31

gets the current lock if any for a given id. If there is a lock this will return a promise that resolves once the lock is unlocked return {Promise}

Parameters

lock

index.js:12-22

Creates a lock on a given ID and returns a resolve function to unlock the lock

Parameters

Returns function the resolve function to call once it to unlock

LICENSE

MPL-2.0)

Built with git-ssb-web