Skip to content

docs: fix stale v1, v6, v7 and CLI details in README - #991

Merged
broofa merged 1 commit into
uuidjs:mainfrom
yxshee:fix/readme-v1-v6-v7-docs
Nov 1, 2026
Merged

broofa merged 1 commit into
uuidjs:mainfrom
yxshee:fix/readme-v1-v6-v7-docs

Conversation

@yxshee

@yxshee yxshee commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

The repo's PR template only asks for benchmark results on considerable changes. This is a docs-only change, so I did not run the benchmark.

I checked the README against the current code on main and found five places where it no longer matches. I made the edits in README_js.md and regenerated README.md with npm run docs, as CONTRIBUTING.md asks.

Changes

  1. v1() options.nsecs unit. The table said it is a number of nanoseconds, 0-10,000. The code treats it as 100-nanosecond intervals (t = msecs * 10000 + nsecs). I checked this by running:

    const base = { node: Uint8Array.of(1, 2, 3, 4, 5, 6), clockseq: 0x1234 };
    const msecs = new Date('2011-11-01').getTime();
    v1({ ...base, msecs, nsecs: 10000 }); // '710ba710-041c-11e1-9234-010203040506'
    v1({ ...base, msecs: msecs + 1, nsecs: 0 }); // '710ba710-041c-11e1-9234-010203040506'

    Both calls return the same UUID, so 10,000 is a full millisecond. I changed the text to "100-nanosecond intervals, should be 0-9,999".

  2. v1() _throws_ row. The table said v1 throws if more than 10M UUIDs/sec are requested. That stopped being true in uuid@11 (see the comment in updateV1State: it now resets the node on nsecs overflow). I stubbed Date.now to a fixed value and called v1() 20,001 times. Nothing threw. I removed the row.

  3. v6() options example. It passed node as a plain array. Version1Options.node is a Uint8Array, so the example does not type-check:

    error TS2345: Argument of type '{ node: number[]; ... }' is not assignable to parameter of type 'Version1Options'.
      Types of property 'node' are incompatible.
    

    I changed it to Uint8Array.of(...), the same as the v1() example. With that change tsc --strict passes, and the generated output in the README stays the same.

  4. v7() description. It said "Create an RFC version 7 (random) UUID". v7 is the Unix Epoch time-based version, and the API summary table already says so. I made the heading match.

  5. uuid --help output. The README copy did not have the uuid v6 line. node dist-node/bin/uuid --help prints it, and uuid v6 works.

Other diffs from regenerating

  • The uuidv6() example output changed from ...-504d... to ...-514d.... That example uses the seeded fake RNG from the top of README_js.md. The new value has the multicast bit set on the random node, which is what fix(v1): set the multicast bit on v1Bytes's own randomly-generated node #973 changed. The README had not been regenerated since then.
  • The Node support paragraph was edited only in README.md (b9ed7c7). I copied that wording into README_js.md so that npm run docs keeps it. The only difference in README.md is one double space that became a single space, which Prettier also asks for.

Checks

  • npm run docs runs without errors
  • npm test: 84 passed, 0 failed
  • npx prettier --check README_js.md passes
  • The commitlint hook passed

- options.nsecs is a count of 100-nanosecond intervals, not
  nanoseconds (nsecs: 10000 gives the same UUID as msecs + 1).
- v1() no longer throws when more than 10M UUIDs/sec are requested.
  Since uuid@11 the node is reset on nsecs overflow instead.
- The v6() options example passed `node` as a plain array, which
  fails to type-check against Version1Options (Uint8Array).
- The v7() description said "(random)"; v7 is the Unix Epoch
  time-based version, as the API summary already says.
- `uuid --help` output was missing the `uuid v6` line.

README.md is regenerated with `npm run docs`. The README_js.md Node
support paragraph is synced from README.md so regenerating keeps the
current wording.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NQDmA3mwGfL83pbg9WQ6ey

@broofa broofa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catches. Thanks for the contribution!

@broofa
broofa merged commit 766d0d2 into uuidjs:main Nov 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants