1
Fork 0

Add a sleep utility function.

This commit is contained in:
Bauke 2023-07-15 21:19:41 +02:00
parent 99180035e3
commit c818362773
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 10 additions and 0 deletions

View File

@ -7,6 +7,7 @@ export * from "./http.js";
export * from "./logging.js"; export * from "./logging.js";
export * from "./query-selectors.js"; export * from "./query-selectors.js";
export * from "./report-a-bug.js"; export * from "./report-a-bug.js";
export * from "./sleep.js";
export * from "./text.js"; export * from "./text.js";
export * from "./user.js"; export * from "./user.js";
export * from "./validators.js"; export * from "./validators.js";

View File

@ -0,0 +1,9 @@
/**
* Promisified {@linkcode window.setTimeout}.
* @param timeout The amount of time in milliseconds to sleep for.
*/
export async function sleep(timeout: number): Promise<void> {
return new Promise((resolve) => {
window.setTimeout(resolve, timeout);
});
}