From bcbe727bad59a339cf631ee7b19dc4c87bfc9537 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 2 Jul 2026 08:41:30 -0700 Subject: [PATCH] Use type alias for byte arrays. --- src/lib/convert/bytes.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/convert/bytes.ts b/src/lib/convert/bytes.ts index 52e2d95..955543c 100644 --- a/src/lib/convert/bytes.ts +++ b/src/lib/convert/bytes.ts @@ -23,10 +23,10 @@ export const bytes = Object.freeze({ /** * Convert a Uint8Aarray of bytes to a base32 string. * - * @param {Uint8Array} bytes - Byte array to convert + * @param {Bytes} bytes - Byte array to convert * @returns {string} Base32 string representation of the input bytes */ - toBase32 (bytes: ArrayBuffer | Uint8Array): string { + toBase32 (bytes: ArrayBuffer | Bytes): string { if (bytes instanceof ArrayBuffer) bytes = new Uint8Array(bytes) const leftover = (bytes.length * 8) % 5 const offset = leftover === 0 @@ -53,10 +53,10 @@ export const bytes = Object.freeze({ * Sum an array of bytes to a decimal integer. If the result is larger than * Number.MAX_SAFE_INTEGER, it will be returned as a bigint. * - * @param {Uint8Array} bytes - Byte array to convert + * @param {Bytes} bytes - Byte array to convert * @returns {bigint|number} Decimal sum of the literal byte values */ - toDec (bytes: Uint8Array): bigint | number { + toDec (bytes: Bytes): bigint | number { let decimal = 0n for (let i = bytes.byteLength; i > 0; i--) { decimal += BigInt(bytes[i - 1]) << (BigInt(bytes.byteLength - i) * 8n) @@ -71,10 +71,10 @@ export const bytes = Object.freeze({ /** * Convert a Uint8Array of bytes to a hexadecimal string. * - * @param {Uint8Array} bytes - Byte array to convert + * @param {Bytes} bytes - Byte array to convert * @returns {string} Hexadecimal string representation of the input bytes */ - toHex (bytes: ArrayBuffer | Uint8Array): string { + toHex (bytes: ArrayBuffer | Bytes): string { if (bytes instanceof ArrayBuffer) bytes = new Uint8Array(bytes) let hex: string = '' for (const byte of bytes) { @@ -86,7 +86,7 @@ export const bytes = Object.freeze({ /** * Convert a Uint8Array of bytes to a UTF-8 text string. * - * @param {Uint8Array} bytes - Byte array to convert + * @param {Bytes} bytes - Byte array to convert * @returns {string} UTF-8 encoded text string */ toUtf8 (bytes: Bytes): string { -- 2.52.0