tickle/modules/utils/wait.mjs
2023-05-09 04:00:53 +02:00

19 lines
396 B
JavaScript

//@ts-check
/**
* Waits the specified amount of time before returning the value
* @param {number} durationMs Duration, in milliseconds. Defaults to 1 second
* @returns
*/
export const wait =
(durationMs = 1000) =>
/**
* @template T
* @param {T} [value]
* @returns {Promise<T>}
*/
(value) =>
new Promise((ok) => setTimeout(ok, durationMs, value));
export default wait;