currency.js is a lightweight JavaScript library for handling currency values.
The library solves floating point precision problems that arise when performing arithmetic with decimal numbers in JavaScript. It works by storing currency values as integers internally, converting between the integer representation and decimal display formats as needed. This approach avoids the rounding errors that occur when JavaScript performs calculations on floating point numbers directly. The library handles any reasonable currency value up to 90,071,992,547,409.91 in the minor currency unit.
The tool suits projects that need reliable currency arithmetic without external dependencies. It works with numbers, strings, or existing currency instances as input, and provides arithmetic methods, formatting options, and locale customization. The formatting system supports custom patterns, separators, decimal characters, and symbols, with built-in support for the Indian Numbering System. Developers can also supply custom format functions when the provided options are insufficient. The library includes an increment option for currencies that require rounding to specific values.
The project maintains a stable, minimal codebase with no external dependencies. Development activity shows consistent attention to bug fixes and feature requests, with responsive engagement on issues and pull requests. The maintainers prioritize backward compatibility and keep the library size small, making it suitable for inclusion in performance-sensitive applications.