Represents an immutable version 1 universally unique identifier (UUID). A UUID represents a 128-bit value.

Usage: TimeUuid.now()

Augments

Constructor

new

TimeUuid

([Date value], [Number ticks], [String or Buffer nodeId], [String or Buffer clockId])

Creates a new instance of Uuid based on the parameters provided according to rfc4122. If any of the arguments is not provided, it will be randomly generated, except for the date that will use the current date.

Parameters:
Name Type Description
value optional Date

The datetime for the instance, if not provided, it will use the current Date.

ticks optional Number

A number from 0 to 10000 representing the 100-nanoseconds units for this instance to fill in the information not available in the Date, as Ecmascript Dates have only milliseconds precision.

nodeId optional String or Buffer

A 6-length Buffer or string of 6 ascii characters representing the node identifier, ie: ‘host01’.

clockId optional String or Buffer

A 2-length Buffer or string of 6 ascii characters representing the clock identifier.

Methods

equals

(Uuid other)

Compares this object to the specified object. The result is true if and only if the argument is not null, is a UUID object, and contains the same value, bit for bit, as this UUID.

Parameters:
Name Type Description
other Uuid

The other value to test for equality.

TimeUuid.fromDate

(Date date, [Number ticks], [String or Buffer nodeId], [String or Buffer clockId])

Generates a TimeUuid instance based on the Date provided using random node and clock values.

Static
This function is static
Parameters:
Name Type Description
date Date

Date to generate the v1 uuid.

ticks optional Number

A number from 0 to 10000 representing the 100-nanoseconds units for this instance to fill in the information not available in the Date, as Ecmascript Dates have only milliseconds precision.

nodeId optional String or Buffer

A 6-length Buffer or string of 6 ascii characters representing the node identifier, ie: ‘host01’. If not provided, a random nodeId will be generated.

clockId optional String or Buffer

A 2-length Buffer or string of 6 ascii characters representing the clock identifier. If not provided a random clockId will be generated.

TimeUuid.fromString

(String value)

Parses a string representation of a TimeUuid

Static
This function is static
Parameters:
Name Type Description
value String
Returns:
Type Description
TimeUuid

getBuffer

()

Gets the bytes representation of a Uuid

Returns:
Type Description
Buffer

getDate

()

Gets the Date representation of this instance.

Returns:
Type Description
Date

getDatePrecision

()

Gets the Date and 100-nanoseconds units representation of this instance.

Returns:
Type Description
Object

getNodeId

()

Returns the node id this instance

Returns:
Type Description
Buffer

getNodeIdString

()

Returns the node id this instance as an ascii string

Returns:
Type Description
String

inspect

()

Provide the name of the constructor and the string representation

Returns:
Type Description
string

TimeUuid.max

()

Returns the biggest possible type 1 uuid with the provided Date.

Static
This function is static

TimeUuid.min

()

Returns the smaller possible type 1 uuid with the provided Date.

Static
This function is static

TimeUuid.now

([String or Buffer nodeId], [String or Buffer clockId])

Generates a TimeUuid instance based on the current date using random node and clock values.

Static
This function is static
Parameters:
Name Type Description
nodeId optional String or Buffer

A 6-length Buffer or string of 6 ascii characters representing the node identifier, ie: ‘host01’. If not provided, a random nodeId will be generated.

clockId optional String or Buffer

A 2-length Buffer or string of 6 ascii characters representing the clock identifier. If not provided a random clockId will be generated.

toJSON

()

Returns the string representation. Method used by the native JSON.stringify() to serialize this instance.

toString

()

Returns a string representation of the value of this Uuid instance. 32 hex separated by hyphens, in the form of 00000000-0000-0000-0000-000000000000.

Returns:
Type Description
String