ts-wait
I'm tired to write a wait function again and agin in my projects, so I make this simple project.
await wait(100)
This lib does not do only this. Mainly it allows to set timetou on function, ethier synchronous or asynchronous:
try {
const func = ()=> {},
const result = await waitUntil(
func,
10000
);
} catch (err) {
if (isTimeoutError(error)) { {
} else {
}
}
It throws an error of type TimeoutError it timeout occurs. The isTimeoutError is a type guard to check is error is a TimeoutError.
To set a timeout on an async function
try {
const result = await waitUntilAsync(async () => {
}, 10000);
} catch (err) {
if (isTimeoutError(error)) {
} else {
}
}