From c30850b74b82c4ff40d91e59203f272f2c51125a Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 22 Aug 2025 02:04:52 -0700 Subject: [PATCH] Allow byte conversion to hex from buffer as well as typed array. --- src/lib/convert.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/convert.ts b/src/lib/convert.ts index c270fb3..ba29b6a 100644 --- a/src/lib/convert.ts +++ b/src/lib/convert.ts @@ -151,7 +151,8 @@ export class bytes { * @param {Uint8Array} bytes - Byte array to convert * @returns {string} Hexadecimal string representation of the input bytes */ - static toHex (bytes: Uint8Array): string { + static toHex (bytes: ArrayBuffer | Uint8Array): string { + if (bytes instanceof ArrayBuffer) bytes = new Uint8Array(bytes) if (bytes.buffer instanceof ArrayBuffer && bytes.buffer.detached) return '' return [...bytes] .map(byte => byte.toString(16).padStart(2, '0')) -- 2.47.3