Merge pull request #103 from jerome-benoit/dependabot/npm_and_yarn/eslint-plugin...
[benchmarks-js.git] / random.mjs
index f814d3d37344900edacfe5d5190f106d64f92c19..16037df91dff6aaaa47880b1247be00525161878 100644 (file)
@@ -1,9 +1,9 @@
-import crypto from 'crypto'
+import { randomInt } from 'node:crypto'
 import Benchmark from 'benny'
 import {
   secureRandom,
   secureRandomWithRandomValues
-} from './benchmark-utils.js'
+} from './benchmark-utils.mjs'
 
 const maximum = 281474976710654
 
@@ -76,9 +76,9 @@ Benchmark.suite(
     max = Math.floor(max)
     if (min != null && min !== 0) {
       min = Math.ceil(min)
-      return Math.floor(crypto.randomInt(min, max + 1))
+      return Math.floor(randomInt(min, max + 1))
     }
-    return Math.floor(crypto.randomInt(max + 1))
+    return Math.floor(randomInt(max + 1))
   }),
   Benchmark.add('Math random integer generator', () => {
     getRandomInteger(maximum)
@@ -100,6 +100,4 @@ Benchmark.suite(
     format: 'table.html',
     details: true
   })
-).catch(err => {
-  console.error(err)
-})
+).catch(console.error)