Repository navigation
test: run the suite against the build with test:dist - #98
Merged
Merged
Conversation
test:dist builds the package and runs the vitest suite against dist/ (`--mode=dist` leaves the -dev export condition off), and `npm test` and `ci:coverage` now include it. The tests import the package by name so the condition decides whether they run on src/ or dist/, and tests/resolve.test.vitest.mjs checks the name resolved to the expected tree.
cldmv-bot Bot
added a commit
that referenced
this pull request
Nov 10, 2026
# `@cldmv/uuid` v1.5.0 Changelog **Release Date**: November 2026 **Release Type**: Minor **Branch**: `release/1.5.0` --- ## Overview v1.5.0 adds `UUID.entropy()`, a helper that builds the `entropy` argument for `UUID.TA()` and `UUID.TB()`. It packs a per-tick counter, a 16-bit fingerprint of an optional seed and random bits into the 49 entropy bits those variants keep (or any other length, with the `bits` option), so two ids minted by one module instance on the same tick never repeat (at any length of 12 bits or more). `TA()` and `TB()` themselves don't change, and ids minted without the helper are exactly as before. The test suite also runs against the built `dist/` now, not only against `src/`, so a bundling problem fails the build instead of reaching a consumer. --- ## ✨ Features ### `UUID.entropy()` ([#103](#103), fixes [#102](#102)) - `UUID.entropy({ seed, precision, bits, onOverflow })` returns a 16-byte `Uint8Array` with bits 79-127 filled by default and a `timestamp` property: the tick the counter was taken on. Stamp the id with it: `UUID.TB(e.timestamp, e)`. - Bit layout of the 49 bits: a 12-bit counter (bits 79-90) that starts each tick at a random value in 0-2047 and counts up, so an instance gets at least 2048 ids per tick and ids from one instance in one tick sort in the order they were made; 16 bits of SHA-1 of the seed (bits 91-106), random when there is no seed; and 21 random bits (bits 107-127). - `bits` sets the length in bits; the default, 49, is the layout above. Any length of 0 or more works ([#105](#105)): the same fields fill the last `bits` bits in the same order, longer lengths get more random bits, and a short one cuts them where it runs out (under 28 bits the seed fingerprint keeps only its top bits, under 12 the counter keeps only its low bits and repeats inside a tick after 2^`bits` calls). The array is 16 bytes, longer past 128 bits. - `precision: "ms"` (default) matches `TB()`. `TA()` stores seconds, so use `precision: "s"` with it. - `onOverflow`: when the counter runs out inside a tick, `"wait"` spins until the next tick and `"advance"` moves to the next tick at once. The default is `"wait"` for milliseconds and `"advance"` for seconds, where a wait could block for up to a second. - The tick never moves backwards. After a clock step back the helper stays on its last tick and keeps counting, and a wait gives up after 1,000,000 readings with no change, so a frozen `Date.now()` (fake timers in a test suite) can't hang it. - The guarantee is per module instance (per worker or thread). Between instances it rests on chance: at the default length, about 2^-32 for two instances with the same seed minting on the same tick, about 2^-48 with no seed. - Browser-safe: it uses the package's own `rng` and `hash` modules, which switch to Web Crypto and a pure-JS SHA-1 under the `browser` condition. - Typed in `types/src/uuid.d.mts` and covered by the consumer type test. ## 🧪 Tests - New `tests/entropy.test.vitest.mjs` and `tests/entropy-browser.test.vitest.mjs`: the bit layout, the seed fingerprint, no repeats inside a tick and across overflow, both overflow modes, clock steps back, the frozen-clock cap, and the browser build ([#103](#103)); the `bits` option at the default, longer, past-128, short and zero lengths ([#105](#105)). - `npm run test:dist` builds and runs the Vitest suites against `dist/` (`--mode=dist` leaves the `uuid-dev` condition off). `npm test` and `ci:coverage` include it, and `tests/resolve.test.vitest.mjs` checks that `@cldmv/uuid` resolved to the tree the run is meant to test ([#98](#98)). ## 📚 Documentation - README: a `UUID.entropy([options])` section with the options, the bit layout, what a custom `bits` length holds, the stamping rule, the scope of the guarantee and examples for `TB` and `TA` ([#103](#103)). The test commands list `test:dist` ([#98](#98)). - **NEW:** [docs/changelog/v1/v1.5.0.md](./v1.5.0.md): this changelog. - README What's New promoted to v1.5.0. ## 🔧 Dependencies - No dependency changes. --- ## Upgrade notes - No breaking changes. `UUID.entropy()` is new and opt-in; existing calls to `TA()`, `TB()` and every other variant behave as in v1.4.0. - When using the helper, always pass its `timestamp` to `TA()`/`TB()`. Passing `undefined` lets them read the clock themselves, which gives up the no-repeat guarantee on counter overflow, with `"advance"`, or after a clock step back. <details> <summary>👥 Contributors</summary> - @Shinrai </details> --- <!-- coverage-start -->  | Metric | Coverage | |--------|----------| | Statements | 82.8% | | Branches | 85.2% | | Functions | 90.3% | | Lines | 82.4% | *Avg: **85.1%** · `72b2436` · Node lts/** <!-- coverage-end --> <!-- co-authors --> Co-authored-by: Shinrai <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
No bug fixes
📦 Dependencies
No dependency updates
🔧 Other Changes
👥 Contributors