Merge pull request #103 from jerome-benoit/dependabot/npm_and_yarn/eslint-plugin...
[benchmarks-js.git] / random.mjs
index e1062c05c7e4a4d17749645af4d8a271ac0fd547..16037df91dff6aaaa47880b1247be00525161878 100644 (file)
@@ -1,4 +1,4 @@
-import crypto from 'crypto'
+import { randomInt } from 'node:crypto'
 import Benchmark from 'benny'
 import {
   secureRandom,
@@ -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)