X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmark-utils.mjs;h=59521b614ebee8564dd93e258bac032bba210ddb;hb=5ae65d5957d343a831259d6f0120d5d39be84ddc;hp=2f1a8629e948a6955d7aca380b84d75bfe22e9cf;hpb=06e5b8561b5144fa4ab80210257b3733e2dcf3af;p=benchmarks-js.git diff --git a/benchmark-utils.mjs b/benchmark-utils.mjs index 2f1a862..59521b6 100644 --- a/benchmark-utils.mjs +++ b/benchmark-utils.mjs @@ -1,4 +1,4 @@ -import crypto from 'crypto' +import crypto, { webcrypto } from 'node:crypto' /** * Generate a cryptographically secure random number in the [0,1[ range @@ -13,7 +13,7 @@ export function secureRandom () { * @returns */ export function secureRandomWithRandomValues () { - return crypto.getRandomValues(new Uint32Array(1))[0] / 0x100000000 + return webcrypto.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)) }