-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
39 lines (33 loc) · 802 Bytes
/
Copy pathutil.js
File metadata and controls
39 lines (33 loc) · 802 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const fs = require('fs-extra')
/**
* Remove directory
* @param String assetDirectory path to the directory to remove
*/
const cleanup = (assetDirectory) => fs.removeSync(assetDirectory)
/**
* Generate random number in range [0, max]
*/
const getRandomInt = (max) =>
Math.floor(Math.random() * Math.floor(max + 1))
/**
* Generate random number in range [min, max]
*/
const getRandomIntInRange = (min, max) =>
Math.floor(Math.random() * (max - min + 1)) + min
/**
* Bluesky post wrapper
*/
const makePost = async (agent, record) => {
return agent.post(record)
}
/**
* Sleep for a specified amount of seconds
*/
const sleep = async (ms) => new Promise((resolve) => setTimeout(resolve, ms))
module.exports = {
cleanup,
getRandomInt,
getRandomIntInRange,
makePost,
sleep,
}