UNPKG

@ssts/frac

Version:

Get a random fractional/decimal number within a range, between two numbers min and max.

2 lines (1 loc) 546 B
var t=(r,n,e=3)=>{if(typeof r!="number")throw new TypeError("min must be a number");if(typeof n!="number")throw new TypeError("max must be a number");if(typeof e!="number")throw new TypeError("fractionDigits must be a number");if(e<0)throw new RangeError(`Invalid fractionDigits value: ${e}. Must be greater than or equal to 0`);let o=parseInt("1"+"0".repeat(Math.floor(e)));return Math.floor((Math.random()*(n-r)+r)*o)/o};typeof window<"u"&&(typeof window.ssts!="object"&&(window.ssts={}),window.ssts.seniorFRAC=t);var a=t;export{a as default};