- Full ESM conversion. If you require the commonjs version of this library, stay on the 1.x version until you are ready to upgrade.
- This library now requires Node 16.
- Switch to built-in Node test runner and assertion library, and removed
nyc
,mocha
andchai
.
- A faster algorithm for negative powers (@oliverlj).
- Yearly dependency update
- Typescript 4, new linting rules, switch to github actions.
- Added
pow()
operation.
- Update dependencies
multiply()
anddivide()
can now accept otherMoney
objects as arguments.
- Added
abs()
function, to remove the sign from values. (@flaktack) - Added
sign()
function to find out if a number is postive, negative or zero (@flaktack).
- Don't round numbers when used with
console.log()
.
- Re-release of 0.8.0 with the correct build artifacts.
- I've also updated
package.json
so we do a correct build before publish, so this issue won't happen again.
- Increased the precision to 20 digits, up from 12. Someone had a need for more than 12 digits, and 20 seems like a reasonable new limit. Perhaps at one point this will be configurable but picking a good default seems like a sane choice right now.
- Re-release: Stripped all development files from the npm package build. This makes the npm package a lot slimmer.
- Added
isLesserThan
,isGreaterThan
,isEqual
,isLesserThanOrEqual
,isGreaterThanOrEqual
methods.
- The last release didn't have all it's files correctly built. This version is a re-release that's properly built.
- Regression from "0.6.2": Negative values were still incorrect for the same bug.
- Fixed critical bug in
toFixed()
function. It can round0.995
to0.100
instead of1
. This bug only appears when rounding decimals should increase the integer part.
- Added
Round.HALF_TOWARDS_0
,Round.TRUNCATE
.
- It's not possible to specify the rounding method. The default is still
HALF_TO_EVEN
but aHALF_AWAY_FROM_0
option has been added.
- Added a
format()
function that simply returns the currency value as a string, with all insignificant 0's removed.
- This library now adds a
toJSON()
function that has a default serialization for JSON files. Example: 1.5 USD will be JSON-stringified as["1.5", "USD"]
. - The Money class is now the default export.
- Support for
divide()
,multiply()
,compare()
. - Added an implementation of the
allocate()
function from Fowler's Enterprise Design Patterns. - Fixed parsing string numbers without a fractional part.
- Added
toSource()
andfromSource()
methods to easily get access to the underlying bigint. Money.value
is now private.- Nice v8 debugger output. Shows the currency + the symbol.
- The rounding method everywhere is now 'Bankers rounding', also known as 'round half to even'. This is a more acceptable rounding for finanical purposes.
- Moved some utilities into the
src/util.ts
function. - Fixed bugs in
toFixed()
. - Higher test coverage.
- Fixed bugs.
- More test coverage
- Support for passing negative and floating point-as-string in constructor.
- Readme with docs.
- First working release. Support for basic arthimetic.
- Temporarily dropped support for a webpack build until they support bigint.
- First started working on this.