From: Chris Duncan Date: Fri, 22 Aug 2025 07:26:03 +0000 (-0700) Subject: Allow ArrayBuffer for converting to base32. X-Git-Tag: v0.10.5~41^2~7 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=2a8137346745b61cd94a80a61a32e2ac086eff60;p=libnemo.git Allow ArrayBuffer for converting to base32. --- diff --git a/src/lib/convert.ts b/src/lib/convert.ts index ae1c8f2..f9f9273 100644 --- a/src/lib/convert.ts +++ b/src/lib/convert.ts @@ -83,7 +83,8 @@ export class bytes { * @param {Uint8Array} bytes - Byte array to convert * @returns {string} Base32 string representation of the input bytes */ - static toBase32 (bytes: Uint8Array): string { + static toBase32 (bytes: ArrayBuffer | Uint8Array): string { + if (bytes instanceof ArrayBuffer) bytes = new Uint8Array(bytes) const leftover = (bytes.length * 8) % 5 const offset = leftover === 0 ? 0