Class Scru64Id

Represents a SCRU64 ID.

Conversion

  • Returns the 64-bit unsigned integer representation.

    Returns bigint

  • Returns the 12-digit canonical string representation.

    Returns string

  • Creates an object from a 64-bit unsigned integer.

    Parameters

    • value: bigint

    Returns Scru64Id

    Throws

    RangeError if the argument is negative or larger than 36^12 - 1.

  • Creates an object from an array of Base36 digit values representing a 12-digit string representation.

    Parameters

    • src: ArrayLike<number>

    Returns Scru64Id

    Throws

    SyntaxError if the argument does not contain a valid string representation.

  • Creates a value from the timestamp and the combined nodeCtr field value.

    Parameters

    • timestamp: number
    • nodeCtr: number

    Returns Scru64Id

    Throws

    RangeError if any argument is negative or larger than their respective maximum value (36^12 / 2^24 - 1 and 2^24 - 1, respectively).

  • Creates an object from a 12-digit string representation.

    Parameters

    • value: string

    Returns Scru64Id

    Throws

    SyntaxError if the argument is not a valid string representation.

Other

  • Creates an object from an 8-byte byte array.

    Parameters

    • bytes: Readonly<Uint8Array>

    Returns Scru64Id

bytes: Readonly<Uint8Array>

An 8-byte byte array containing the 64-bit unsigned integer representation in the big-endian (network) byte order.

  • get nodeCtr(): number
  • Returns the nodeId and counter field values combined as a single 24-bit integer.

    Returns number

  • get timestamp(): number
  • Returns the timestamp field value.

    Returns number

  • Creates an object from this.

    Note that this class is designed to be immutable, and thus clone() is not necessary unless properties marked as read-only are modified.

    Returns Scru64Id

  • Returns a negative integer, zero, or positive integer if this is less than, equal to, or greater than other, respectively.

    Parameters

    Returns number

  • Returns true if this is equivalent to other.

    Parameters

    Returns boolean

  • Returns a part of bytes as an unsigned integer.

    Parameters

    • beginIndex: number
    • endIndex: number

    Returns number

  • Represents this in JSON as a 12-digit canonical string.

    Returns string

  • Creates an object from the internal representation, an 8-byte byte array containing the 64-bit unsigned integer representation in the big-endian (network) byte order.

    This method does NOT shallow-copy the argument, and thus the created object holds the reference to the underlying buffer.

    Parameters

    • bytes: Readonly<Uint8Array>

    Returns Scru64Id

    Throws

    RangeError if the length of the argument is not 8 or the argument contains an unsigned integer larger than 36^12 - 1.