Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 774 Bytes

readme.md

File metadata and controls

62 lines (40 loc) · 774 Bytes

Advanced wait group for JS/TS (with types)

Installation

    npm i advanced_waitgroup_js

Usage

done

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

ultimatum

import WaitGroup from 'advanced_waitgroup_js'

const wg = new WaitGroup()

wg.add(2)

const p = wg.wait()

setTimeout(() => {
    wg.ultimatum()
}, 3000)

await p

ttl and onOver

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())