Comparing version 6.1.0 to 7.0.0
{ | ||
"name": "utilsac", | ||
"version": "6.1.0", | ||
"version": "7.0.0", | ||
"description": "JavaScript General Purpose Utility Functions", | ||
@@ -5,0 +5,0 @@ "main": "files.js", |
export { | ||
randomInt | ||
randomPositiveInt, | ||
randomInt, | ||
randomFloat | ||
}; | ||
@@ -9,8 +11,34 @@ | ||
@param {uint} maxExclusive | ||
@return {uint} random positive integer | ||
*/ | ||
const randomPositiveInt = function (maxExclusive = 2) { | ||
return Math.floor(Math.random() * maxExclusive); | ||
}; | ||
/** | ||
Returns a random integer between minInclusive (included) and | ||
maxExlusive (excluded) | ||
@param {int} maxExclusive | ||
@param {int} maxExclusive | ||
@return {int} random integer | ||
*/ | ||
const randomInt = function (maxExclusive = 2) { | ||
return Math.floor(Math.random() * maxExclusive); | ||
const randomInt = function (minInclusive = 0, maxExclusive = 2) { | ||
return minInclusive + Math.floor(Math.random() * (maxExclusive - minInclusive)); | ||
}; | ||
/** | ||
Returns a random number between minInclusive (included) and | ||
maxExlusive (excluded) | ||
@param {number} maxExclusive | ||
@param {number} maxExclusive | ||
@return {number} random number | ||
*/ | ||
const randomFloat = function (minInclusive = 0, maxExclusive = 1) { | ||
return minInclusive + (Math.random() * (maxExclusive - minInclusive)); | ||
}; |
21816
408