back to home

uuidjs / uuid

Generate RFC-compliant UUIDs in JavaScript

15,243 stars
949 forks
4 issues
TypeScriptJavaScriptShell

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing uuidjs/uuid in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/uuidjs/uuid)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

uuid For the creation of RFC9562 (formerly RFC4122) UUIDs • **Complete** - Support for all RFC9562 UUID versions • **Cross-platform** - Support for... • Typescript • Chrome, Safari, Firefox, and Edge • NodeJS • React Native / Expo • **Secure** - Uses modern API for random values • **Compact** - Zero-dependency, tree-shakable • **CLI** - command line utility > [!NOTE] > > Starting with CommonJS is no longer supported. See implications and motivation for details. Quickstart **1. Install** **2. Create a UUID** For timestamp UUIDs, namespace UUIDs, and other options read on ... API Summary | | | | | --- | --- | --- | | | The nil UUID string (all zeros) | New in | | | The max UUID string (all ones) | New in | | | Convert UUID string to array of bytes | New in | | | Convert array of bytes to UUID string | New in | | | Create a version 1 (timestamp) UUID | | | | Create a version 6 UUID from a version 1 UUID | New in | | | Create a version 3 (namespace w/ MD5) UUID | | | | Create a version 4 (random) UUID | | | | Create a version 5 (namespace w/ SHA-1) UUID | | | | Create a version 6 (timestamp, reordered) UUID | New in | | | Create a version 1 UUID from a version 6 UUID | New in | | | Create a version 7 (Unix Epoch time-based) UUID | New in | | ~~ ~~ | "Intentionally left blank" | | | | Test a string to see if it is a valid UUID | New in | | | Detect RFC version of a UUID | New in | API uuid.NIL The nil UUID string (all zeros). Example: uuid.MAX The max UUID string (all ones). Example: uuid.parse(str) Convert UUID string to array of bytes | | | | --------- | ---------------------------------------- | | | A valid UUID | | _returns_ | | | _throws_ | if is not a valid UUID | > [!NOTE] > Ordering of values in the byte arrays used by and follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. Example: uuid.stringify(arr[, offset]) Convert array of bytes to UUID string | | | | -------------- | ---------------------------------------------------------------------------- | | | -like collection of 16 values (starting from ) between 0-255. | | [ = 0] | Starting index in the Array | | _returns_ | | | _throws_ | if a valid UUID string cannot be generated | > [!NOTE] > Ordering of values in the byte arrays used by and follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. Example: uuid.v1([options[, buffer[, offset]]]) Create an RFC version 1 (timestamp) UUID | | | | --- | --- | | [ ] | with one or more of the following properties: | | [ ] | RFC "node" field as an of byte values (per 4.1.6) | | [ ] | RFC "clock sequence" as a between 0 - 0x3fff | | [ ] | RFC "timestamp" field ( of milliseconds, unix epoch) | | [ ] | RFC "timestamp" field ( of nanoseconds to add to , should be 0-10,000) | | [ ] | of 16 random bytes (0-255) used to generate other fields, above | | [ ] | Alternative to , a that returns an of 16 random bytes (0-255) | | [ ] | or subtype (e.g. Node.js ). If provided, binary UUID is written into the array, starting at | | [ = 0] | Index to start writing UUID bytes in | | _returns_ | UUID if no is specified, otherwise returns | | _throws_ | if more than 10M UUIDs/sec are requested | Example: Example using : uuid.v1ToV6(uuid) Convert a UUID from version 1 to version 6 uuid.v3(name, namespace[, buffer[, offset]]) Create an RFC version 3 (namespace w/ MD5) UUID API is identical to , but uses "v3" instead. > [!IMPORTANT] > Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_." uuid.v4([options[, buffer[, offset]]]) Create an RFC version 4 (random) UUID | | | | --- | --- | | [ ] | with one or more of the following properties: | | [ ] | of 16 random bytes (0-255) | | [ ] | Alternative to , a that returns an of 16 random bytes (0-255) | | [ ] | or subtype (e.g. Node.js ). If provided, binary UUID is written into the array, starting at | | [ = 0] | Index to start writing UUID bytes in | | _returns_ | UUID if no is specified, otherwise returns | Example: Example using predefined values: uuid.v5(name, namespace[, buffer[, offset]]) Create an RFC version 5 (namespace w/ SHA-1) UUID | | | | --- | --- | | | | | | Namespace UUID | | [ ] | or subtype (e.g. Node.js ). If provided, binary UUID is written into the array, starting at | | [ = 0] | Index to start writing UUID bytes in | | _returns_ | UUID if no is specified, otherwise returns | > [!NOTE] > The RFC and namespaces are available as and . Example with custom namespace: Example with RFC namespace: uuid.v6([options[, buffer[, offset]]]) Create an RFC version 6 (timestamp, reordered) UUID This method takes the same arguments as uuid.v1(). Example using : uuid.v6ToV1(uuid) Convert a UUID from version 6 to version 1 uuid.v7([options[, buffer[, offset]]]) Create an RFC version 7 (random) UUID | | | | --- | --- | | [ ] | with one or more of the following properties: | | [ ] | RFC "timestamp" field ( of milliseconds, unix epoch) | | [ ] | of 16 random bytes (0-255) used to generate other fields, above | | [ ] | Alternative to , a that returns an of 16 random bytes (0-255) | | [ ] | 32-bit sequence between 0 - 0xffffffff. This may be provided to help ensure uniqueness for UUIDs generated within the same millisecond time interval. Default = random value. | | [ ] | or subtype (e.g. Node.js ). If provided, binary UUID is written into the array, starting at | | [ = 0] | Index to start writing UUID bytes in | | _returns_ | UUID if no is specified, otherwise returns | Example: ~~uuid.v8()~~ **_"Intentionally left blank"_** > [!NOTE] > Version 8 (experimental) UUIDs are "for experimental or vendor-specific use cases". The RFC does not define a creation algorithm for them, which is why this package does not offer a method. The and methods do work with such UUIDs, however. uuid.validate(str) Test a string to see if it is a valid UUID | | | | --------- | ----------------------------------------…