Skip to content

Instantly share code, notes, and snippets.

@ErickWendel
Last active February 16, 2021 19:56
Show Gist options
  • Save ErickWendel/a0af493c14bec93a38a018f0a149e3f6 to your computer and use it in GitHub Desktop.
Save ErickWendel/a0af493c14bec93a38a018f0a149e3f6 to your computer and use it in GitHub Desktop.
// 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