npm i advanced_waitgroup_js
import WaitGroup from 'advanced_waitgroup_js'
const wg = new WaitGroup()
wg.add(2)
const p = wg.wait()
setTimeout(() => {
wg.done()
}, 5000)
setTimeout(() => {
wg.done()
}, 3000)
await p
import WaitGroup from 'advanced_waitgroup_js'
const wg = new WaitGroup()
wg.add(2)
const p = wg.wait()
setTimeout(() => {
wg.ultimatum()
}, 3000)
await p
import WaitGroup from 'advanced_waitgroup_js'
const wg = new WaitGroup()
console.log(new Date())
wg.add(0, 20, alert('time passed for wait group'))
await wg.wait()
console.log(new Date())