Developer Guide
Contributing
Setup
Code
Conventions
- Functional API only —
add(a, b), nevera.add(b). Ops acceptDecimalInputand returnDecimal. - Immutability —
Decimalinstances are frozen value objects. - PG parity —
divdefault scale follows PostgreSQLselect_div_scale;HALF_UPis the default rounding (= PGround()). - No runtime dependencies, no Primebrick deps — this is the leaf of the dependency graph.
- Docs — English; TSDoc on every public function (not the class). The
rendered
api-reference.mdxis regenerated mechanically — never edit it.
Adding an operation
- Implement in
src/ops.ts(or a newsrc/module) — pure bigint math, noMath.*on the value. - Export from
src/index.ts. - Extend the matrix tables in
test/decimal.test.ts— include negative, zero, scale-mismatched, and boundary cases. pnpm buildregeneratesdocs/dev-guide/api-reference.mdx— commit it with the change.
Docs pipeline
pnpm extract-docs runs TypeDoc → docs/dev-guide/_extracted/api.json, then
scripts/render-api-reference.mjs → api-reference.mdx. prebuild runs the
chain on every build, so artifacts stay fresh — commit them with your diff.
The institutional site syncs this repo's docs/dev-guide/ from main
(scheduled docs-release workflow in primebrick-v3-docs). There is no
docs/user-guide/ on purpose — decimal is dev-documentation only and must
never enter the product KB.
GitFlow & releases
Work on feature/* from develop. Releases: release/X.Y.Z (minor) or
hotfix/X.Y.Z (patch) → merge to main → tag X.Y.Z → CI publishes to npm
via OIDC trusted publishing → merge main back to develop.
Last modified on