All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Initial release
rounded()default export withhalfUpandbankersrounding methodsrounded.cash()for physical denomination rounding (nearest 0.05 / 0.10 / 0.25 etc.)rounded.currency()for ISO 4217 currency-aware rounding- Named exports:
halfUp,bankers,cash,currency,CURRENCY_PRECISION RoundingMethod,RoundedOptions,CurrencyRoundingMethod,CurrencyOptions,CashOptions, andCurrencyCodeTypeScript typessrc/utils/guard.ts— null-safety for all public inputssrc/utils/precision.ts— string-based decimal shift to prevent float drift- Full TypeScript support with type definitions in
dist/types - Zero dependencies
- Dual package support (CommonJS + ESM) via
tsconfig.esm.jsonandtsconfig.cjs.json - Post-build script
scripts/fix-cjs.mjsto rename.js → .cjsand patch internalrequire()paths - Test suite with Vitest covering
halfUp,bankers,cash,currency, and the mainrounded()wrapper
halfUp: Standard receipt/POS rounding — ties always round toward +∞bankers: Round half to even — reduces cumulative bias in high-volume transaction setscash: Rounds to nearest physical denomination — configurable vianearestoption (default0.05)precision: Configurable decimal places onrounded(), default2method: Selectable rounding algorithm onrounded()androunded.currency()
- Input validation via
guard()—NaN,null,undefined,Infinity, and-Infinityall returnnull, never throw - Float drift prevention via
toPrecision(15)string-based decimal shifting before any arithmetic — guards against cases like1.005 * 100 = 100.4999...