moderndash
Advanced tools
Comparing version 3.7.1 to 3.7.2
@@ -247,14 +247,11 @@ // src/array/chunk.ts | ||
// src/crypto/randomFloat.ts | ||
var shiftLeft20Bits = 2 ** 20; | ||
var shiftRight52Bits = 2 ** -52; | ||
function randomFloat(min, max) { | ||
if (min >= max) { | ||
if (min >= max) | ||
throw new Error("max must be greater than min"); | ||
} | ||
const range2 = max - min; | ||
const randomBuffer = new Uint32Array(2); | ||
crypto.getRandomValues(randomBuffer); | ||
const mantissa = randomBuffer[0] * shiftLeft20Bits + (randomBuffer[1] >>> 12); | ||
const randomFloat2 = mantissa * shiftRight52Bits; | ||
return min + randomFloat2 * range2; | ||
const randomBigInt = BigInt(randomBuffer[0]) << 20n | BigInt(randomBuffer[1]) >> 12n; | ||
const maxNumber = 2 ** 52 - 1; | ||
const fraction = Number(randomBigInt) / maxNumber; | ||
return min + fraction * (max - min); | ||
} | ||
@@ -261,0 +258,0 @@ |
{ | ||
"name": "moderndash", | ||
"version": "3.7.1", | ||
"version": "3.7.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A Typescript-First utility library inspired by Lodash. Optimized for modern browsers.", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
297575
3245