Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/uuid/mod.ts>v1.generate

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function v1.generate
import { v1 } from "https://deno.land/std@0.218.0/uuid/mod.ts";
const { generate } = v1;

Generates a RFC4122 v1 UUID (time-based).

Examples

Example 1

import { generate } from "https://deno.land/std@0.218.0/uuid/v1.ts";

const options = {
  node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
  clockseq: 0x1234,
  msecs: new Date("2011-11-01").getTime(),
  nsecs: 5678,
};

generate(options); // "710b962e-041c-11e1-9234-0123456789ab"

Parameters

optional
options: V1Options | null

Can use RFC time sequence values as overwrites.

optional
buf: number[]

Can allow the UUID to be written in byte-form starting at the offset.

optional
offset: number

Index to start writing on the UUID bytes in buffer.

Returns

string | number[]