-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.mjs
More file actions
24 lines (24 loc) · 842 Bytes
/
utils.mjs
File metadata and controls
24 lines (24 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**Inverts the prompt type from `description` to `build` and vice versa.
*
* @param {string} promptType - The current prompt type, either `description` or `build`.
* @returns {string} The inverted prompt type.
*/
export function invertPromptType(promptType) {
if (promptType == "description") return "build"
return "description"
}
/**Returns a random integer between min (inclusive) and max (inclusive)
*
* @param {number} min - The minimum value (inclusive)
* @param {number} max - The maximum value (inclusive)
* @returns {number} A random integer between min and max
*/
export function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
/**@param {number} time
* @returns {Promise<void>}
*/
export function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}