functions.ts 423 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import logger from './Logger'

export const pErr = (err: Error) => {
    if (err) {
        logger.err(err)
    }
}

export const getRandomInt = () => {
    return Math.floor(Math.random() * 1_000_000_000_000)
}

export async function asyncForEach<T>(array: Array<T>, callback: (item: T, index: number) => void) {
    for (let index = 0; index < array.length; index++) {
        await callback(array[index], index)
    }
}