git ssb

0+

wanderer🌟 / lockmap



Tree: 658e6a90035883776dcc7357a920cbc84e7d3c67

Files: 658e6a90035883776dcc7357a920cbc84e7d3c67 / tests / index.js

474 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