WorkerFragment class for worker IDs.

Hierarchy

  • default
    • default

Constructors

  • Throws

    [VALUE_INVALID_TYPE] If value is not a number.

    Throws

    [VALUE_INVALID_RANGE] If value is not within 0 and 2 ** bits - 1

    Parameters

    • bits: number

      The number of bits for the fragment.

    • Optional value: number

      A persistent ID value to use for the fragment.

      Defaults to the current worker ID if omitted.

    Returns default

Properties

bitMask: bigint

The bit mask used to isolate the fragment's bits from the snowflake.

bitMask is equal to maxValue << bitShift

bitMaskHex: string

The hexadecimal representation of the bit mask as string.

bitShift: bigint

The number of bits for left and right shifting.

bitShift is equal to the number of bits on the right side

bits: number
identifier: string

The fragment identifier.

maxValue: bigint

The maximum value that can be represented by this fragment.

maxValue is equal to 2 ** bits - 1

value: bigint

The current value of the fragment.

Methods

  • Internal

    Returns the worker's ID.

    Remarks

    The value is masked by the maxValue to fit in the fragment's bits.

    Returns

    The worker's ID.

    Returns bigint

  • Internal

    Parameters

    • bitsRightSide: number

    Returns void

Generated using TypeDoc