From: Jérôme Benoit Date: Fri, 25 Aug 2023 19:57:12 +0000 (+0200) Subject: refactor: node 16 compatibility X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a551f3165f8e39ad826de48c772d1203a5c9c9de;p=benchmarks-js.git refactor: node 16 compatibility Signed-off-by: Jérôme Benoit --- diff --git a/benchmark-utils.mjs b/benchmark-utils.mjs index 2f1a862..d3757b5 100644 --- a/benchmark-utils.mjs +++ b/benchmark-utils.mjs @@ -1,4 +1,4 @@ -import crypto from 'crypto' +import crypto, { webcrypto } from '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 } /**