fix: array buffer typing

This commit is contained in:
Shibo Lyu 2025-03-11 19:03:48 +08:00
parent a10a49152e
commit 598ed931e0

View file

@ -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("");
}