async-flag
Promise based flag for asynchronous condition, for javascript/Nodejs
npm i async-flag
Basic
const AsyncFlag = let flag = //Set the flag somewhere else //wait for the flaglet result = await flag //result will be 'hello'
Error case
let flag = 'my-conditiopn' //Set the error somewhere else flag //prints 'something wrong'
Timeout
let flag = 'myFlag' flag //expected timeout, prints: "AsyncFlag timeout: myFlag"flag //expected timeout, prints: "AsyncFlag timeout: myFlag"flag //expected resolve, prints "hello"flag //expected resolve, prints "hello"
Reset
let flag = flagflag //reset the promise.flag