rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
18 lines • 582 B
JavaScript
import { _Debug } from "../../debug/_debug.js";
/**
* @public
* Create a random value between min and max.
*
* @remarks
* NaN input will cause a debug error. Max greater than min will cause a debug error.
*
* See {@link mathBoundRandom}.
*/
export function mathBoundRandom(min, max) {
_BUILD.DEBUG && _Debug.runBlock(() => {
_Debug.assert(min < max, "min must be smaller than max");
_Debug.assert(!isNaN(min) && !isNaN(max), "nan input not supported");
});
return Math.random() * (max - min) + min;
}
//# sourceMappingURL=math-bound-random.js.map