AbakoJS
abakojsZero-dependency monetary arithmetic for JS & TS. Precise rounding, fee and discount calculation, value partitioning, formatting, and crypto asset support. Ships as ESM + CJS.
# install
npm install abakojsyarn add abakojs# why it exists
Every JS project that touches money ends up reinventing the same wheel: How do I round 0.1 + 0.2 without floating-point surprises? How do I split a total across N recipients without losing cents? After solving these problems repeatedly across e-commerce, fintech, and crypto projects, I distilled the patterns into AbakoJS. The name comes from the abacus (the oldest calculation tool) because the goal is the same: reliable, exact arithmetic that never surprises you.
# features
All operations use integer-scaled math internally, avoiding IEEE 754 floating-point drift entirely. 0.1 + 0.2 === 0.30, always.
Apply percentage fees, flat surcharges, tiered discounts, and chained promotions with a fluent API. Rounding mode is configurable per-operation.
Split a total into N parts proportionally or equally, distributing any remainder penny in a deterministic, auditable way.
Format monetary values following CLDR locale rules (currency symbol, grouping separators, and decimal format) without pulling in a heavy i18n library.
# highlights
- Zero external dependencies: nothing to audit, nothing to update
- Works in Node.js, Deno, Bun, and the browser with the same import
- Ships dual ESM + CJS so it drops into any project without config
- Handles crypto assets with configurable decimal precision (up to 18 places)
- Tested against the ICU standard rounding edge cases