MONEY VALUES WITH CLEAR BOUNDARIES
money-safe
Accept decimal strings at product boundaries, store integer minor units, and move auditable money payloads between services without guessing.
checkout payload
INSTALL
pnpm add @crapthings/money-safeimport { amount } from '@crapthings/money-safe';
const subtotal = amount('19.99', 'CNY').times(3);
const total = subtotal.minus('5.00').plusMinor(1200);
const payment = total.toJSON();
// { amountMinor: '6697', currency: 'CNY', minorUnit: 2 }
Clear Boundariesmoney-safe stays focused
Handles amount shape
decimal, minor, JSONParse, calculate, allocate, format, and serialize values deliberately.
Does not own business policy
no FX, ledger, tax engineKeep exchange rates, accounting rules, and provider flows in your app.
Keeps review points visible
rounding is explicitNumber conversion and ratio math make rounding choices visible in code.