Open Source Packages

AbakoJS

abakojs
npmFinanceTypeScriptFeaturedv2.3.2MIT

Zero-dependency monetary arithmetic for JS & TS. Precise rounding, fee and discount calculation, value partitioning, formatting, and crypto asset support. Ships as ESM + CJS.

Published Jan 2024
Updated Apr 2026

Installation

$npm install abakojs
$yarn 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

Precise Arithmetic

All operations use integer-scaled math internally, avoiding IEEE 754 floating-point drift entirely. 0.1 + 0.2 === 0.30 — always.

💸Fee & Discount Engine

Apply percentage fees, flat surcharges, tiered discounts, and chained promotions with a fluent API. Rounding mode is configurable per-operation.

🔀Value Partitioning

Split a total into N parts proportionally or equally, distributing any remainder penny in a deterministic, auditable way.

🌍Locale Formatting

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
moneycurrencyfinancearithmetictypescriptesm

References & Links

Related Packages