Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

General utilities.

Functions

byteArrayToHexStr

  • byteArrayToHexStr(byteArray: Uint8Array): string
  • Converts a Uint8Array into a string with base 16 hex digits. It doesn't include an opening '0x'.

    export

    Parameters

    • byteArray: Uint8Array

      Uint8Array to convert to hex.

    Returns string

    String with base 16 hex digits.

byteToHexStr

  • byteToHexStr(byte: number, prefix?: boolean): string
  • Convert a positive integer byte (0 to 0xFF) into a hex string.

    export

    Parameters

    • byte: number

      Number to convert into a hex string.

    • Default value prefix: boolean = false

      Boolean to add '0x' to the beginning of the string.

    Returns string

    String with hex value, padded to always at least 2 characters.

byteToHexStrFast

  • byteToHexStrFast(byte: number): string
  • A version of byteToHexStr() without input sanitation, only to be called when the caller can guarantee the input is a positive integer between 0 and 0xFF.

    export

    Parameters

    • byte: number

      Number to convert into a hex string.

    Returns string

    String with hex value, padded to always have 2 characters.

concatUint8Arrays

  • concatUint8Arrays(arraysToConcat: Uint8Array[]): Uint8Array
  • Concatenates an array of Uint8Arrays into a single Uint8Array.

    export

    Parameters

    • arraysToConcat: Uint8Array[]

      Arrays to concatenate.

    Returns Uint8Array

    Single concatenated Uint8Array.

hexStrToBytes

  • hexStrToBytes(hexStr: string): Uint8Array
  • Convert from a string with a hexadecimal number into a Uint8Array byte array.

    export

    Parameters

    • hexStr: string

      A string with a hexadecimal number.

    Returns Uint8Array

    A Uint8Array with the number broken down in bytes.

Generated using TypeDoc