CCC Docs
    Preparing search index...
    • Return the number of bytes occupied by hexLike.

      This function efficiently calculates the byte length of hex-like values. For valid Hex strings, it uses a fast-path helper. For other types, it converts to bytes first.

      Parameters

      • hexLike: BytesLike

        Hex-like value (Hex string, Uint8Array, ArrayBuffer, or iterable of numbers).

      Returns number

      Byte length of hexLike.

      bytesLen("0x48656c6c6f") // 5
      bytesLen(new Uint8Array([1, 2, 3])) // 3
      bytesLen(new ArrayBuffer(4)) // 4
      bytesLen([1, 2]) // 2

      May throw if hexLike contains invalid byte values when passed to bytesFrom.

      • bytesLenUnsafe - Fast version for already-validated Hex strings
      • bytesFrom - Convert values to Bytes (Uint8Array)

      Prefer direct .length/.byteLength access on Uint8Array/ArrayBuffer when you already have bytes. Use bytesLen() only when you need length without performing additional operations.