Stephen Whitmore committed Fix license URL again, using a markdown footnote.Latest: 0bcd9ac on 11/18/2017, 1:14:09 AM | |
π | .travis.yml |
π | LICENSE |
π | README.md |
π | index.js |
π | package-lock.json |
π | package.json |
π | tests |
README.md
SYNOPSIS :lock: :globe_with_meridians:
Creates a promise based map of locks that can be used as a semaphore
INSTALL
npm install lockmap
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.get(id)
console.log('here now!')
API
constructor
Creates a new instance of LockMap
lock
Creates a lock on a given ID and returns a resolve function to unlock the lock
Parameters
id
any
Returns Function the resolve function to call once it to unlock
get
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
Parameters
id
Returns Promise
LICENSE
Built with git-ssb-web