- Solves the accuracy problems of the accountingjs library (http://openexchangerates.github.io/accounting.js) by using a bigdecimal implementation (credits http://mikemcl.github.io/big.js) instead of floatingpoint.
- ships as ESM, CJS, and a standalone browser bundle, with TypeScript declarations
Add via npm:
npm install stutzjs
Then import:
import money from "stutzjs"; // ESM
// or
const money = require("stutzjs").default; // CJSOr load the standalone bundle directly in a browser (exposes window.money):
<script src="https://elekktrisch.github.io/stutzjs/stutz.standalone.js"></script>var stutz = money.of("CHF", "1234654987.123");
var formattedMoney = stutz.formatMoney(); // "CHF 1'234'654'987.12"var stutz = money.parse("CHF 1'234'654'987.12");
console.log(stutz.getAmount().toFixed(3)); // "1234654987.120"
console.log(stutz.getCurrencyCode()); // "CHF" see Demo for all configuration options.