Last active
February 16, 2021 19:56
-
-
Save ErickWendel/a0af493c14bec93a38a018f0a149e3f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.mjs | |
// nvm use 15 && node index.mjs | |
{ | |
const getRandomInteger = (max = 100) => { | |
return Math.floor(Math.random() * max) | |
} | |
console.log('Math.random', getRandomInteger()) | |
} | |
import { promisify } from 'util' | |
import { randomInt } from 'crypto' | |
const randomIntAsync = promisify(randomInt) | |
const getRandomInteger = async (max = 100) => { | |
return randomIntAsync(max) | |
} | |
console.log('crypto.randomInt', await getRandomInteger()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment