Variable v1Const

v1: {
    generate: ((options?: GenerateOptions) => string);
    validate: ((id: string) => boolean);
} = ...

Generator and validator for UUIDv1.

Type declaration

  • generate: ((options?: GenerateOptions) => string)
      • (options?): string
      • Generates a UUIDv1.

        Parameters

        • options: GenerateOptions = {}

          Can use RFC time sequence values as overwrites.

        Returns string

        Returns a UUIDv1 string or an array of 16 bytes.

        import { generate, validate } from "@std/uuid/v1";
        import { assert } from "@std/assert";

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

        const uuid = generate(options);
        assert(validate(uuid as string));
  • validate: ((id: string) => boolean)
      • (id): boolean
      • Determines whether a string is a valid UUIDv1.

        Parameters

        • id: string

          UUID value.

        Returns boolean

        true if the string is a valid UUIDv1, otherwise false.

        import { validate } from "@std/uuid/v1";
        import { assert, assertFalse } from "@std/assert";

        assert(validate("ea71fc60-a713-11ee-af61-8349da24f689"));
        assertFalse(validate("fac8c1e0-ad1a-4204-a0d0-8126ae84495d"));
import { v1 } from "@std/uuid";
import { assert } from "@std/assert";

const uuid = v1.generate();
assert(v1.validate(uuid as string));