mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-21 07:16:15 -04:00
13 lines
347 B
TypeScript
13 lines
347 B
TypeScript
import {randomBytes} from 'crypto'
|
|
|
|
const random = () => randomBytes(4).readUInt32LE(0) / 0x100000000
|
|
|
|
const randFromArray = (array: any[]) => array[Math.floor(random() * array.length)]
|
|
|
|
const randIntFromInterval = (min: number, max: number) => Math.floor(random() * (max - min) + min)
|
|
|
|
export {
|
|
randFromArray,
|
|
randIntFromInterval,
|
|
random
|
|
}
|