typeit
Version:
The most versatile animated typing utility on the planet.
21 lines (17 loc) • 399 B
text/typescript
/**
* Fire a callback after a delay, and add the timeout ID to a referenced array.
*/
let wait = (
callback: Function,
delay: number | undefined,
timeouts: number[],
) => {
return new Promise<void>((resolve) => {
let cb = async () => {
await callback();
resolve();
};
timeouts.push(setTimeout(cb, delay || 0) as unknown as number);
});
};
export default wait;