• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

philihp / pcg / 26028074792
100%

Build:
DEFAULT BRANCH: main
Ran 18 May 2026 10:32AM UTC
Jobs 1
Files 5
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

18 May 2026 10:31AM UTC coverage: 89.51% (+0.5%) from 88.976%
26028074792

push

github

web-flow
feat: make PCGState JSON-serializable (#179) (#330)

* feat: make PCGState JSON-serializable

Refactor PCGState so it contains only values that survive JSON.stringify /
JSON.parse. This unblocks use cases like local-first apps that need to
persist or sync RNG state across clients (issue #179).

The previous shape stored a getOutput function and four bigints (state,
streamId, algorithm.multiplier, algorithm.increment) directly on the
state object. Functions can't be serialized at all, and bigints are not
JSON-native.

Changes:
- Represent 64-bit values as { hi, lo } pairs of unsigned 32-bit numbers
  (Uint64), which fit comfortably inside JSON.
- Move multiplier, increment, and the output function table out of state
  into a module-level config registry keyed by a `variant` tag stored on
  the state. The only variant today is 'pcg32'.
- Replace the per-state getOutput closure with a getOutput(pcg) helper
  that looks up the function from the variant config.
- Expose toBigInt / fromBigInt helpers for callers that need to inspect
  the underlying 64-bit values.

The internal math still uses bigints; conversion happens at the edges of
each step. This is a breaking change to the PCGState shape.

* refactor: inline single-use bigint temporaries

Drop streamIdBig, two stateBig temporaries, the config local inside
getOutput, and the initial local inside createPcg's factory — each was
referenced exactly once. Keeps the hot-loop outputFn lookup in
randomIntImpl hoisted, since it's executed per iteration.

---------

Co-authored-by: Claude <noreply@anthropic.com>

25 of 34 branches covered (73.53%)

Branch coverage included in aggregate %.

28 of 29 new or added lines in 2 files covered. (96.55%)

103 of 109 relevant lines covered (94.5%)

12682.53 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
85.85
1.4% src/createPcg.ts
Jobs
ID Job ID Ran Files Coverage
1 26028074792.1 18 May 2026 10:32AM UTC 5
89.51
GitHub Action Run
Source Files on build 26028074792
  • Tree
  • List 5
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • bd2d2f66 on github
  • Prev Build on main (#26026019871)
  • Next Build on main (#26031894998)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc