git ssb

0+

wanderer🌟 / lockmap



Tree: 38f718562e84b8cd2135ff0de9da998771d971c5

Files: 38f718562e84b8cd2135ff0de9da998771d971c5 / tests / index.js

476 bytesRaw
1const tape = require('tape')
2const LockMap = require('../')
3
4tape('lockmap tests', async (t) => {
5 t.plan(2)
6 // create a new lock map
7 const lockmap = new LockMap()
8 const id = 'test'
9
10 let first = true
11
12 // set a lock for an id
13 const unlock = lockmap.lock(id)
14
15 setTimeout(() => {
16 // do some async work
17 t.equals(first, true)
18 first = false
19 unlock()
20 }, 300)
21
22 // wait until the lock resolves
23 await lockmap.getLock(id)
24 t.equals(first, false)
25})
26

Built with git-ssb-web