From 1132c9f1ccaf940a4ce7a5aefe83f1f4e683469a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1nos=20Veres?= Date: Fri, 31 May 2024 13:24:17 +0200 Subject: [PATCH] refactor: code clarity --- packages/ogre/src/hash.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ogre/src/hash.ts b/packages/ogre/src/hash.ts index 4caa984..ebe2fe0 100644 --- a/packages/ogre/src/hash.ts +++ b/packages/ogre/src/hash.ts @@ -39,12 +39,12 @@ export function digest(obj: any, algorithm = "SHA-256"): Promise { if (isBrowser()) { const buf = await crypto.subtle.digest(algorithm, hashInput); const h = "0123456789abcdef"; - new Uint8Array(buf).forEach((v) => { + for (const v of new Uint8Array(buf)) { digest += h[v >> 4] + h[v & 15]; - }); + } } else { const nodeAlg = algorithm.toLowerCase().replace("-", ""); - digest = (await import("crypto")) + digest = (await import("node:crypto")) .createHash(nodeAlg) .update(Buffer.from(hashInput)) .digest("hex"); // eslint-disable-line