diff --git a/source/utilities/exports.ts b/source/utilities/exports.ts index bd997ce..72bd8a6 100644 --- a/source/utilities/exports.ts +++ b/source/utilities/exports.ts @@ -7,6 +7,7 @@ export * from "./http.js"; export * from "./logging.js"; export * from "./query-selectors.js"; export * from "./report-a-bug.js"; +export * from "./sleep.js"; export * from "./text.js"; export * from "./user.js"; export * from "./validators.js"; diff --git a/source/utilities/sleep.ts b/source/utilities/sleep.ts new file mode 100644 index 0000000..c1bcb2f --- /dev/null +++ b/source/utilities/sleep.ts @@ -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 { + return new Promise((resolve) => { + window.setTimeout(resolve, timeout); + }); +}