1.0.2 • Published 4 years ago
@codebundlesbyvik/number-operations v1.0.2
number-operations
JavaScript helper functions for number operations.
Installation
// Install package from npm
npm install @codebundlesbyvik/number-operationsimport getRandomIntUnder from "@codebundlesbyvik/number-operations";Functions
getRandomIntUnder(max, includeMax)
Generate and return a random integer below a given number.
⚠️ Makes use of Math.random(), which ISN'T cryptographically secure. Do NOT use this for generating secure, random integers. ⚠️
Parameters
* indicates required
- * max(Number): Depending onincludeMax, the returned integer will be either equal to or below this number.
- includeMax(- Boolean): Whether or not to include- maxwhen generating the integer. Default is undefined, which functions as- false.
Usage
getRandomIntUnder(10)
// > 7
getRandomIntUnder(10, true)
// > 10License
MIT © Viktor Chin-Kon-Sung