/**
* 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
* 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)
/**
* 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) {
/**
* 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 {