X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=random.js;h=c3e5c4a8383c3821c223c40921a95ea63da8bb3e;hb=34fe8c9d05157bc0678edad5e6c730a30c9b6983;hp=272d8e6969c23f71c234cad66ca93d8ffbe889dd;hpb=804a63757c95b0f5b802233ba678cac3d1a7a886;p=benchmarks-js.git diff --git a/random.js b/random.js index 272d8e6..c3e5c4a 100644 --- a/random.js +++ b/random.js @@ -1,9 +1,9 @@ +const crypto = require('crypto') const Benchmark = require('benny') const { secureRandom, secureRandomWithRandomValues } = require('./benchmark-utils') -const crypto = require('crypto') const maximum = 281474976710654 @@ -74,7 +74,7 @@ Benchmark.suite( ), Benchmark.add('Crypto random integer generator', (max = maximum, min = 0) => { max = Math.floor(max) - if (min !== undefined && min !== 0) { + if (min != null && min !== 0) { min = Math.ceil(min) return Math.floor(crypto.randomInt(min, max + 1)) }