- static async sleepWorkerFunction (
- data,
- ms,
- rejection = false,
- rejectionMessage = ''
- ) {
- return new Promise((resolve, reject) => {
- setTimeout(
- () =>
- rejection === true
- ? reject(new Error(rejectionMessage))
- : resolve(data),
- ms
- )
- })
+const sleepTaskFunction = async (
+ data,
+ ms,
+ rejection = false,
+ rejectionMessage = ''
+) => {
+ return await new Promise((resolve, reject) => {
+ setTimeout(
+ () =>
+ rejection === true
+ ? reject(new Error(rejectionMessage))
+ : resolve(data),
+ ms
+ )
+ })
+}
+
+const generateRandomInteger = (max = Number.MAX_SAFE_INTEGER, min = 0) => {
+ if (max < min || max < 0 || min < 0) {
+ throw new RangeError('Invalid interval')
+ }
+ max = Math.floor(max)
+ if (min != null && min !== 0) {
+ min = Math.ceil(min)
+ return Math.floor(Math.random() * (max - min + 1)) + min