@twinfinity/core
    Preparing search index...

    Class Uint32Bits

    Provides methods to manipulate and read individual and bits in the numbers held by a a typed array Uint32Array.

    Index

    Constructors

    Properties

    data: Pick<LazyResizableTypedArray<number, Uint32Array>, "buffer" | "uint8">

    uint32 numbers to read/manipulate

    Accessors

    • get bytes(): Uint32Bytes

      Get a Uint32Bytes instance that can be used to manipulate the number that the bytes in data.buffer represents. The number is specified by setting dataOffset. Calling mutating methods in the Uint32Bytes will trigger the _onValueChanged callback. and isChanged will also be changed accordingly.

      Returns Uint32Bytes

    • get dataOffset(): number

      Gets the offset of the number in data the Uint32Bits instance is working with

      Returns number

    • set dataOffset(o: number): void

      Sets the offset of the number in data the Uint32Bits instance is working with, Also resets the isChanged property to false.

      Parameters

      • o: number

      Returns void

    • get isChanged(): boolean

      Whether the number in data that dataOffset currently points to has changed since dataOffset was last called. Can only be changed by calling methods and properties on this Uint32Bits instance.

      Returns boolean

    • get value(): number

      The uint32 number that the Uint32Bits instance is currently working with (specified by dataOffset).

      Returns number

    • set value(v: number): void

      Replace the uint32 number in data that dataOffset points to. Will trigger _onValueChanged callback and isChanged will also be changed accordingly.

      Parameters

      • v: number

      Returns void

    Methods

    • Returns the number stored at a bit up to the bit specified by bit + size.

      Parameters

      • bit: BitIndex

        bit

      • size: number

        number of bits starting at bit.

      Returns number

      The number stored at [bit, bit + size].

    • Check if a bit is on or off in data [dataOffset].

      Parameters

      Returns boolean

      true if bit is on. Otherwise false.

    • Store a number at bits defined by bit and bit + size. Only the first size bits of val will be used.

      Parameters

      • bit: BitIndex

        bit to start storing val at.

      • size: number

        number of bits to store val at.

      • val: number

        Value to store

      Returns Uint32Bits

      The Uint32Bits instance. Useful for chaining.

    • Converts data[dataOffset] to a binary string

      Returns string

      Binary string representation (32 positions.)

    • Returns the number stored at a specified bit up to the bit specified by bit + size.

      Parameters

      • value: number

        The value to extract the number from.

      • bit: BitIndex

        The starting bit position.

      • size: number

        The number of bits to extract.

      Returns number

      The number stored at [bit, bit + size].

    • Checks if a bit is on or off in the given value.

      Parameters

      • value: number

        The value to check.

      • bit: BitIndex

        The bit to check.

      Returns boolean

      true if the bit is on, otherwise false.

    • Creates a mask with bits specified by bit to bit + size set to 1. All other bits are 0

      Parameters

      • bit: BitIndex

        bit

      • size: number

        number of bits to set

      Returns number

      mask

    • Sets a bit to 0 in the given value.

      Parameters

      • value: number

        The original value.

      • bit: BitIndex

        The bit to set to 0.

      Returns number

      The modified value with the bit set to 0.

    • Sets a bit to 1 in the given value.

      Parameters

      • value: number

        The original value.

      • bit: BitIndex

        The bit to set to 1.

      Returns number

      The modified value with the bit set to 1.

    • Sets a bit to on/off in the given value.

      Parameters

      • value: number

        The original value.

      • bit: BitIndex

        The bit to set on/off.

      • truthy: unknown

        truthy sets the bit to 1, falsy sets it to 0.

      Returns number

      The modified value with the bit set.

    • Stores a number at bits defined by bit and bit + size. Only the first size bits of val will be used.

      Parameters

      • value: number

        The original value.

      • bit: BitIndex

        The starting bit position.

      • size: number

        The number of bits to store.

      • val: number

        The value to store.

      Returns number

      The modified value with the number stored at the specified bits.

    • converts n to a binary string

      Parameters

      • n: number

        Number to convert to a binary string.

      Returns string

      Binary string representation (32 positions.)