Class: TimeUuid

types~ TimeUuid

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

Usage: TimeUuid.now()

Constructor

new TimeUuid(valueopt, ticksopt, nodeIdopt, clockIdopt)

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 Attributes Description
value Date <optional>
The datetime for the instance, if not provided, it will use the current Date.
ticks Number <optional>
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 String | Buffer <optional>
A 6-length Buffer or string of 6 ascii characters representing the node identifier, ie: 'host01'.
clockId String | Buffer <optional>
A 2-length Buffer or string of 6 ascii characters representing the clock identifier.

Extends

Methods

(static) fromDate(date, ticksopt, nodeIdopt, clockIdopt)

Generates a TimeUuid instance based on the Date provided using random node and clock values.
Parameters:
Name Type Attributes Description
date Date Date to generate the v1 uuid.
ticks Number <optional>
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 String | Buffer <optional>
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 String | Buffer <optional>
A 2-length Buffer or string of 6 ascii characters representing the clock identifier. If not provided a random clockId will be generated.

(static) fromString(value) → {TimeUuid}

Parses a string representation of a TimeUuid
Parameters:
Name Type Description
value String
Returns:
Type
TimeUuid

(static) max()

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

(static) min()

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

(static) now(nodeIdopt, clockIdopt)

Generates a TimeUuid instance based on the current date using random node and clock values.
Parameters:
Name Type Attributes Description
nodeId String | Buffer <optional>
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 String | Buffer <optional>
A 2-length Buffer or string of 6 ascii characters representing the clock identifier. If not provided a random clockId will be generated.

equals(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.
Inherited From:
Overrides:

getBuffer() → {Buffer}

Gets the bytes representation of a Uuid
Inherited From:
Overrides:
Returns:
Type
Buffer

getDate() → {Date}

Gets the Date representation of this instance.
Returns:
Type
Date

getDatePrecision() → {Object}

Gets the Date and 100-nanoseconds units representation of this instance.
Returns:
Type
Object

getNodeId() → {Buffer}

Returns the node id this instance
Returns:
Type
Buffer

getNodeIdString() → {String}

Returns the node id this instance as an ascii string
Returns:
Type
String

inspect() → {string}

Provide the name of the constructor and the string representation
Inherited From:
Overrides:
Returns:
Type
string

toJSON()

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

toString() → {String}

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.
Inherited From:
Overrides:
Returns:
Type
String