whiteflag-js
    Preparing search index...

    Class BinaryBuffer

    A class representing a binary buffer BinaryBuffer

    Objects of this class represent a binary encoded piece of data, e.g. a Whiteflag message, that can be manipulated at bit level. This class provides the basic (not Whiteflag-specific) functionality for other Whiteflag packages to encode and decode binary Whiteflag messages.

    Index

    Properties

    length: number

    The number of used bits in the buffer

    Methods

    • Function

      Appends bytes from a number array to the binary buffer appendBytes

      Parameters

      • byteArray: number[]

        an array of numbers representing bytes

      • nBits: number = 0

        the number of used bits to append

      Returns BinaryBuffer

      the updated binary buffer

    • Function

      Appends a hexadecimal string to the binary buffer appendHex

      Parameters

      • hexString: string

        a hexadecimal string

      • nBits: number = 0

        the number of used bits to append

      Returns BinaryBuffer

      the updated binary buffer

    • Function

      Appends a Uint8Array to the binary buffer appendU8a

      Parameters

      • u8array: Uint8Array

        an array of 8-bit unsigned integers

      • nBits: number = 0

        the number of used bits to append

      Returns BinaryBuffer

      the updated binary buffer

    • Function

      Shortens the binary buffer to the length of the specified bits crop

      Parameters

      • nBits: number

        the number of used bits, or, if negative, the number of bits to remove

      Returns BinaryBuffer

      the updated binary buffer

    • Extracts the specified bits from the binary buffer

      Parameters

      • startBit: number

        the first bit to extract (inclusive)

      • endBit: number = -1

        the final bit of the extraction (exclusive), negative means until end of buffer

      Returns BinaryBuffer

      a new binary buffer with the extracted bits

    • Extracts the specified bits from the binary buffer to a hexadecimal string

      Parameters

      • startBit: number

        the first bit to extract (inclusive)

      • endBit: number = -1

        the final bit of the extraction (exclusive), negative means until end of buffer

      Returns string

      a hexadecimal string with the extracted data

    • Function

      Extracts the specified bits from the binary buffer to a Uint8Array extractU8a

      Parameters

      • startBit: number

        the first bit to extract (inclusive)

      • endBit: number = -1

        the final bit of the extraction (exclusive), negative means until end of buffer

      Returns Uint8Array

      an array of 8-bit unsigned integers with the extracted data

    • Function

      Inserts bytes from a number array at the start of the binary buffer insertBytes

      Parameters

      • byteArray: number[]

        an array of numbers representing bytes

      • nBits: number = 0

        the number of used bits to insert

      Returns BinaryBuffer

      the updated binary buffer

    • Function

      Inserts a hexadecimal string at the start of the binary buffer insertHex

      Parameters

      • hexString: string

        a hexadecimal string

      • nBits: number = 0

        the number of used bits to insert

      Returns BinaryBuffer

      the updated binary buffer

    • Function

      Inserts a Uint8Array at the start of the binary buffer insertU8a

      Parameters

      • u8array: Uint8Array

        an array of 8-bit unsigned integers

      • nBits: number = 0

        the number of used bits to insert

      Returns BinaryBuffer

      the updated binary buffer

    • Function

      Shifts bits in the buffer to the left, shrinking the buffer shiftLeft

      Parameters

      • shift: number

        the number of bits to shift to the left

      Returns BinaryBuffer

      the shifted binary buffer

    • Function

      Shifts bits in the buffer to the right, enlarging the buffer shiftRight

      Parameters

      • shift: number

        the number of bits to shift to the right

      Returns BinaryBuffer

      the shifted binary buffer

    • Function

      Gives the value of the binary buffer as a hexadecimal string toHex

      Returns string

      a hexadecimal string

    • Function

      Gives the value of the binary buffer as a Uint8Array toU8a

      Returns Uint8Array

      an array of 8-bit unsigned integers

    • Function

      Creates a binary buffer from bytes in a number array fromBytes

      Parameters

      • byteArray: number[]

        an array of numbers representing bytes

      • nBits: number = 0

        the number of used bits

      Returns BinaryBuffer

      a new binary buffer

    • Function

      Creates a binary buffer from a hexadecimal string fromHex

      Parameters

      • hexString: string

        a hexadecimal string

      • nBits: number = 0

        the number of used bits

      Returns BinaryBuffer

      a new binary buffer

    • Function

      Creates a binary buffer from a Uint8Array fromU8a

      Parameters

      • u8array: Uint8Array

        an array of 8-bit unsigned integers

      • nBits: number = 0

        the number of used bits

      Returns BinaryBuffer

      a new binary buffer