uuid: Generate Version 7 UUIDs or Random UUIDs

View source: R/utilities.R

uuidR Documentation

Generate Version 7 UUIDs or Random UUIDs

Description

This function generates one or more UUIDs (Universally Unique Identifiers). By default, it generates Version 7 UUIDs, which are time-ordered and suitable for use cases requiring efficient indexing and sorting by creation time. Alternatively, random Version 4 UUIDs can be generated by setting usetime = FALSE.

Usage

uuid(n = 1, uppercase = FALSE, usetime = FALSE)

Arguments

n

Integer. Number of UUIDs to generate. Default is 1.

uppercase

Logical. If TRUE, the generated UUIDs are returned in uppercase letters. Default is FALSE.

usetime

Logical. If TRUE, generates Version 7 UUIDs using the current timestamp. If FALSE, generates random Version 4 UUIDs. Default is FALSE.

Details

  • Version 7 UUIDs: These are time-ordered UUIDs based on the current timestamp in milliseconds since the Unix epoch (⁠1970-01-01 00:00:00 UTC⁠). They are ideal for scenarios requiring chronological sorting or indexing.

  • Version 4 UUIDs: These are randomly generated UUIDs that do not depend on time, ensuring uniqueness through random hexadecimal values.

Value

A character vector of UUIDs of length n.

Examples

library(pliman)
# Generate a single UUID
uuid()

# Generate 5 UUIDs in uppercase
uuid(n = 3, uppercase = TRUE)

# Generate two random UUIDs
uuid(n = 2, usetime = FALSE)


pliman documentation built on Aug. 21, 2025, 5:46 p.m.

Related to uuid in pliman...