From 598ed931e0b20be914202f1eb82fd4a526192ee9 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Tue, 11 Mar 2025 19:03:48 +0800 Subject: [PATCH] fix: array buffer typing --- crypto/utils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/utils.ts b/crypto/utils.ts index b30a8ef..35caffe 100644 --- a/crypto/utils.ts +++ b/crypto/utils.ts @@ -1,5 +1,6 @@ -export function bufToHex(buf: ArrayBufferLike): string { - return [...new Uint8Array(buf)].map((x) => x.toString(16).padStart(2, "0")) +export function bufToHex(buf: ArrayBufferLike | Uint8Array): string { + const u8Array = buf instanceof Uint8Array ? buf : new Uint8Array(buf); + return [...u8Array].map((x) => x.toString(16).padStart(2, "0")) .join(""); }