Skip to content

Commit

Permalink
Add sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaitanLyss committed Aug 21, 2024
1 parent 1ca33b7 commit e36d7a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@selenite/commons",
"version": "0.18.21",
"version": "0.19.0",
"repository": "github:ShaitanLyss/selenite-commons",
"license": "MIT",
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export * as XML from './xml';
export * from './xml';
export * as Storage from './storage.js';
export * from './storage.js';
export * as Promise from './promise.js';
export * from './promise.js';
export * as Layout from './layout';
export * from './layout';
export { v4 as uuidv4 } from 'uuid';
Expand Down
17 changes: 17 additions & 0 deletions src/lib/utils/promise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Utils for working with promises.
*
* Promises are used in JavaScript to handle asynchronous operations. They are a way to handle the result of an asynchronous operation once it completes.
*
* You can await the completion of a promise using the `await` keyword. This will pause the execution of the current function until the promise resolves.
* @module
*/

/**
* Returns a promise that resolves after a delay.
* @param ms - the number of miliseconds to wait before resolving the promise.
* @returns Promise that resolves after the specified delay.
*/
export function sleep(ms: number) {
return new Promise((r) => setTimeout(r, ms));
}

0 comments on commit e36d7a4

Please sign in to comment.