uuid

This module provides UUID generating and parsing functions. I was adaped from this module.

Functions

uuid.v1([options[, buffer[, offset]]])

Generate and return a RFC4122 v1 (timestamp-based) UUID.

Arguments:
  • options

    Optional object with uuid state to apply. Properties may include:

    • node - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
    • clockseq - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
    • msecs - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
    • nsecs - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if msecs is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.
  • buffer – Array or buffer where UUID bytes are to be written.
  • offset – Starting index in buffer at which to begin writing. :returns: The buffer, if specified, otherwise the string form of the UUID.

Note

The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime.

uuid.v4([options[, buffer[, offset]]])

Generate and return a RFC4122 v4 UUID.

Arguments:
  • options – Optional object with uuid state to apply. Unused at the moment.
  • buffer – Array or buffer where UUID bytes are to be written.
  • offset – Starting index in buffer at which to begin writing.
Returns:

The buffer, if specified, otherwise the string form of the UUID.

uuid.parse(id[, buffer[, offset]])
uuid.unparse(buffer[, offset])

Parse and unparse UUIDs.

Arguments:
  • id – UUID(-like) string
  • buffer – Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used.
  • offset – Starting index in buffer at which to begin writing. Default: 0.