refactor: cleanup import
[benchmarks-js.git] / benchmark-utils.mjs
index ac10249991b7bf1cc6b9345e3fc8e22c4ef189f3..7c7832e897d76061383214a3763142fa68159c6a 100644 (file)
@@ -1,19 +1,19 @@
-import crypto from 'crypto'
+import { randomBytes, getRandomValues } from 'node:crypto'
 
 /**
  * Generate a cryptographically secure random number in the [0,1[ range
  * @returns
  */
 export function secureRandom () {
-  return crypto.randomBytes(4).readUInt32LE() / 0x100000000
+  return randomBytes(4).readUInt32LE() / 0x100000000
 }
 
 /**
- *  Generate a cryptographically secure random number in the [0,1[ range
+ * Generate a cryptographically secure random number in the [0,1[ range
  * @returns
  */
 export function secureRandomWithRandomValues () {
-  return crypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000
+  return getRandomValues(new Uint32Array(1))[0] / 0x100000000
 }
 
 /**
@@ -93,5 +93,5 @@ export function generateRandomObject (
  * @returns
  */
 export async function sleep (ms) {
-  return new Promise(resolve => setTimeout(resolve, ms))
+  return await new Promise(resolve => setTimeout(resolve, ms))
 }