Skip to main content

@std/uuid@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)
default

Generators and validators for UUIDs for versions v1, v3, v4 and v5.

Functions

f
isNil(id: string): boolean

Check if the passed UUID is the nil UUID.

f
v1.generate(
options?: V1Options | null,
buf?: number[],
offset?: number
): string | number[]

Generates a RFC4122 v1 UUID (time-based).

f
v1.validate(id: string): boolean

Validates the UUID v1.

f
v3.generate(
namespace: string,
data: Uint8Array
): Promise<string>

Generate a RFC4122 v3 UUID (MD5 namespace).

f
v3.validate(id: string): boolean

Validate that the passed UUID is an RFC4122 v3 UUID.

f
v4.validate(id: string): boolean

Validate that the passed UUID is an RFC4122 v4 UUID.

f
v5.generate(
namespace: string,
data: Uint8Array
): Promise<string>

Generate a RFC4122 v5 UUID (SHA-1 namespace).

f
v5.validate(id: string): boolean

Validate that the passed UUID is an RFC4122 v5 UUID.

f
validate(uuid: string): boolean

Test a string to see if it is a valid UUID.

f
version(uuid: string): number

Detect RFC version of a UUID.

Interfaces

I

The options used for generating a v1 UUID in generate.

  • clockseq: number

    A 14-bit value used to avoid duplicates that could arise when the clock is set backwards in time or if the node ID changes (0 - 16383).

  • msecs: number

    The number of milliseconds since the Unix epoch (January 1, 1970).

  • node: number[]

    An array of 6 bytes that represents a 48-bit IEEE 802 MAC address.

  • nsecs: number

    The number of nanoseconds to add to V1Options.msecs (0 - 10,000).

  • random: number[]

    An array of 16 random bytes (0 - 255).

  • rng: () => number[]

    A function that returns an array of 16 random bytes (0 - 255). Alternative to V1Options.random.

Namespaces

N
No documentation available
N
No documentation available
N
No documentation available
N
No documentation available

Variables

v
NAMESPACE_DNS: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"

Name string is a fully-qualified domain name.

v
NAMESPACE_OID: "6ba7b812-9dad-11d1-80b4-00c04fd430c8"

Name string is an ISO OID.

v
NAMESPACE_URL: "6ba7b811-9dad-11d1-80b4-00c04fd430c8"

Name string is a URL.

v
NAMESPACE_X500: "6ba7b814-9dad-11d1-80b4-00c04fd430c8"

Name string is an X.500 DN (in DER or a text output format).

v
NIL_UUID: "00000000-0000-0000-0000-000000000000"

The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.

constants

Variables

v
NAMESPACE_DNS: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"

Name string is a fully-qualified domain name.

v
NAMESPACE_OID: "6ba7b812-9dad-11d1-80b4-00c04fd430c8"

Name string is an ISO OID.

v
NAMESPACE_URL: "6ba7b811-9dad-11d1-80b4-00c04fd430c8"

Name string is a URL.

v
NAMESPACE_X500: "6ba7b814-9dad-11d1-80b4-00c04fd430c8"

Name string is an X.500 DN (in DER or a text output format).

v1

Functions

f
generate(
options?: V1Options | null,
buf?: number[],
offset?: number
): string | number[]

Generates a RFC4122 v1 UUID (time-based).

f
validate(id: string): boolean

Validates the UUID v1.

Interfaces

I

The options used for generating a v1 UUID in generate.

  • clockseq: number

    A 14-bit value used to avoid duplicates that could arise when the clock is set backwards in time or if the node ID changes (0 - 16383).

  • msecs: number

    The number of milliseconds since the Unix epoch (January 1, 1970).

  • node: number[]

    An array of 6 bytes that represents a 48-bit IEEE 802 MAC address.

  • nsecs: number

    The number of nanoseconds to add to V1Options.msecs (0 - 10,000).

  • random: number[]

    An array of 16 random bytes (0 - 255).

  • rng: () => number[]

    A function that returns an array of 16 random bytes (0 - 255). Alternative to V1Options.random.

v3

Functions

f
generate(
namespace: string,
data: Uint8Array
): Promise<string>

Generate a RFC4122 v3 UUID (MD5 namespace).

f
validate(id: string): boolean

Validate that the passed UUID is an RFC4122 v3 UUID.

v4

Functions

f
validate(id: string): boolean

Validate that the passed UUID is an RFC4122 v4 UUID.

v5

Functions

f
generate(
namespace: string,
data: Uint8Array
): Promise<string>

Generate a RFC4122 v5 UUID (SHA-1 namespace).

f
validate(id: string): boolean

Validate that the passed UUID is an RFC4122 v5 UUID.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.