Skip to main content

RootGuidUtils

Utility class for working with Root GUIDs, providing methods to convert between different formats (UUID, GUID, and string) and to extract metadata like timestamps.

Methods

stringToUint8Array()

static stringToUint8Array(uuid: string): Uint8Array

Parameters

ParameterType
uuidstring

Returns

Uint8Array


toGuid()

static toGuid<T>(data: undefined | RootUuid): T

Converts a RootUuid to a generic type T, typically used for converting to RootGuid.

Type Parameters

Type Parameter
T extends string

Parameters

ParameterTypeDescription
dataundefined | RootUuidThe UUID data to convert.

Returns

T

The converted GUID value.


toGuidNullable()

static toGuidNullable<T>(data: undefined | null | RootUuid): undefined | T

Converts a nullable RootUuid to a generic type T, returning undefined if the input is null or undefined.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
dataundefined | null | RootUuidThe nullable UUID data to convert.

Returns

undefined | T

The converted GUID value or undefined.


toMilliseconds()

static toMilliseconds(strData: string): number

Converts a GUID string to a timestamp in milliseconds since the ROOT_EPOCH.

Parameters

ParameterTypeDescription
strDatastringThe GUID string to extract the timestamp from.

Returns

number

The timestamp in milliseconds.

Throws

Will throw an error if the input string is null or invalid.


toRootGuidType()

static toRootGuidType(strData: string): RootGuidType

Extracts the RootGuidType from a string.

Parameters

ParameterTypeDescription
strDatastringThe GUID string to extract the type from.

Returns

RootGuidType

The extracted RootGuidType value.


toString()

static toString(data: undefined | RootUuid): string

Converts a RootUuid to a base64 encoded string.

Parameters

ParameterTypeDescription
dataundefined | RootUuidThe UUID data to convert.

Returns

string

The base64 string representation of the UUID.


toStringNullable()

static toStringNullable(data: undefined | null | RootUuid): undefined | string

Converts a nullable RootUuid to a string, returning undefined if the input is null or undefined.

Parameters

ParameterTypeDescription
dataundefined | null | RootUuidThe nullable UUID data to convert.

Returns

undefined | string

The base64 string representation or undefined.


toUuid()

static toUuid(strData: RootGuid): RootUuid

Converts a RootGuid string to a RootUuid object.

Parameters

ParameterTypeDescription
strDataRootGuidThe GUID string to convert.

Returns

RootUuid

The RootUuid object.

Throws

Will throw an error if the input string is empty or invalid.


toUuidNullable()

static toUuidNullable(strData: undefined | null | RootGuid): undefined | RootUuid

Converts a nullable RootGuid string to a RootUuid object, returning undefined if the input is null or undefined.

Parameters

ParameterTypeDescription
strDataundefined | null | RootGuidThe nullable GUID string to convert.

Returns

undefined | RootUuid

The RootUuid object or undefined.


toUuidString()

static toUuidString<T>(guid: undefined | null | T): string

Converts a nullable RootGuid to standard UUID formatted string, returning blank if the input is null or undefined;

Type Parameters

Type Parameter
T extends string

Parameters

ParameterTypeDescription
guidundefined | null | TThe nullable GUID string to convert.

Returns

string

string