mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
refactor: change separate tools by category
This commit is contained in:
21
core/stdlib/src/async/sleep/index.ts
Normal file
21
core/stdlib/src/async/sleep/index.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @name sleep
|
||||
* @category Async
|
||||
* @description Delays the execution of the current function by the specified amount of time
|
||||
*
|
||||
* @param {number} ms - The amount of time to delay the execution of the current function
|
||||
* @returns {Promise<void>} - A promise that resolves after the specified amount of time
|
||||
*
|
||||
* @example
|
||||
* await sleep(1000);
|
||||
*
|
||||
* @example
|
||||
* sleep(1000).then(() => {
|
||||
* console.log('Hello, World!');
|
||||
* });
|
||||
*
|
||||
* @since 0.0.3
|
||||
*/
|
||||
export function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
Reference in New Issue
Block a user