math-random
Advanced tools
Comparing version 1.0.0 to 1.0.1
module.exports = (function (global) { | ||
var uint32 = 'Uint32Array' in global | ||
var crypto = global.crypto || global.msCrypto | ||
var rando = typeof crypto.getRandomValues === 'function' | ||
var rando = crypto && typeof crypto.getRandomValues === 'function' | ||
var good = uint32 && crypto && rando | ||
@@ -11,3 +11,4 @@ if (!good) return Math.random | ||
function random () { | ||
return crypto.getRandomValues(arr)[0] / max | ||
crypto.getRandomValues(arr) | ||
return arr[0] / max | ||
} | ||
@@ -14,0 +15,0 @@ |
{ | ||
"name": "math-random", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "a drop-in replacement for Math.random that uses cryptographically secure random number generation, where available", | ||
@@ -5,0 +5,0 @@ "main": "node.js", |
2878
48