Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@dinero.js/core

dinerojs234.4kMIT2.0.0-alpha.1TypeScript support: included

Common code between Dinero.js packages

money, monetary, amount, immutable

readme

Dinero.js

Stability: alpha CircleCI NPM

Dinero.js lets you create, calculate, and format money safely in JavaScript and TypeScript.
v2.dinerojs.com/docs


Money is complex, and the primitives of the language aren't enough to properly represent it. Dinero.js is a JavaScript library that lets you express monetary values, but also perform mutations, conversions, comparisons, formatting, and overall make money manipulation easier and safer in your application.

ℹ️ Dinero.js v2 is currently in alpha. For v1, check the v1 branch and docs.

📦 Install

npm install dinero.js@alpha

# or

yarn add dinero.js@alpha

⚡️ Quick start

Dinero objects are minimal. Every function in dinero.js is side-effect free, allowing you only to bundle exactly what you use.

import { USD } from '@dinero.js/currencies';
import { dinero, add } from 'dinero.js';

const d1 = dinero({ amount: 500, currency: USD });
const d2 = dinero({ amount: 800, currency: USD });

add(d1, d2);

Check out the quick start guide on the documentation.

📚 Documentation

The documentation lets you learn about all aspects of the library.

  • Getting started to get up and running quickly with Dinero.js
  • Core concepts to learn about the underlying principles behind the library
  • Guides to dig deeper into specific use cases.
  • API for a comprehensive list of available functions and their parameters.
  • FAQ for common answers to questions you might have

Visit the full documentation to know more.

👥 Contributors

Dinero.js contributors

From v1


Sarah Dayan

Yacine Hmito

Scott Trinh

Rolandas Barysas

Luiz "Bills"

Leonardo Dino

Roman Komarov

Juan Garcia

Freddy Robinson

Andy Burke

Andre Wiggins

David DeSandro

Max Körlinge

Ilia Ermolin

Kevin Brown

Sean Walker

John Nguyen

Sudarsan Balaji

📜 License

MIT


Powered by Vercel

changelog

2.0.0-alpha.14 (2023-02-27)

Bug Fixes

  • isPositive: return false with zero (#728) (140fe68)
  • up, down, halfUp: fix handling of numbers close to 0 and rounding of integer results (#711) (6b30aa0), closes #710 #713

2.0.0-alpha.13 (2022-12-19)

Bug Fixes

  • toDecimal: preserve negative sign for leading zeros (#693) (e6f290d), closes #692

2.0.0-alpha.12 (2022-12-09)

Bug Fixes

  • toDecimal: teach toDecimal how to handle negative units (#690) (81c5566)

2.0.0-alpha.11 (2022-12-04)

Features

  • provide better support for non-decimal currencies (#309) (e7e9a19), closes #294

BREAKING CHANGES

  • ** the toUnit and the toFormat functions were removed.

2.0.0-alpha.10 (2022-11-19)

Bug Fixes

  • dinero.js: don't accept extra fields inside the currency options on create (#673) (9e72f9e)

2.0.0-alpha.9 (2022-11-04)

Bug Fixes

  • currencies: add missing ANG export (#447) (8a0f67b)
  • trimScale: check for zero value in countTrailingZeros (#448) (6eefe8b)

Reverts

  • revert snapshot process (78db2dd)

2.0.0-alpha.8 (2021-08-08)

Bug Fixes

  • core: use equal function to compare currency base and exponent (ac4724f)
  • calculator-bigint: avoid transpiling exponentiation operator (53bf974)

Features

  • expose calculator types (b17bfc1)

2.0.0-alpha.7 (2021-07-26)

Bug Fixes

  • dinero.js: properly re-export types and rounding functions (d40a7e2)

Features

  • dinero.js: re-export createDinero (d8d149f)

2.0.0-alpha.6 (2021-07-21)

Bug Fixes

  • currencies: use proper base and exponents for MRU and MGA (ac2bb8d)

2.0.0-alpha.5 (2021-07-19)

Features

2.0.0-alpha.4 (2021-07-16)

2.0.0-alpha.3 (2021-07-13)

2.0.0-alpha.2 (2021-07-12)

2.0.0-alpha.1 (2021-07-09)

This alpha release brings the new major version of Dinero.js. To learn more, head over to the documentation.


See previous releases.