Skip to content

Releases: bpierre/dnum

2.17.0

07 Dec 15:19
1810553

Choose a tag to compare

This version adds CJS compatibility, making dnum usable in both ESM and CJS environments.

"exports": {
  ".": {
    "types": "./dist/index.d.ts",
    "import": "./dist/index.js",
    "require": "./dist/index.cjs"
  }
}

Also:

  • vite => bunup
  • pnpm => bun
  • eslint => oxlint
  • vitest => bun:test

2.16.0

03 Dec 14:05
31d1273

Choose a tag to compare

This version fixes an issue where isDnum() would accept arrays with more than 2 elements as valid Dnum values.

See #22 for details.

Thanks @snigdha920 🙏

2.15.0

21 May 20:26
b34cceb

Choose a tag to compare

This version fixes an issue where using dnum.format() with decimalsRounding: "ROUND_UP" could end up by rounding the last digit up when no rounding is needed.

See #20 and #21 for details.

Thanks @freeatnet for both reporting and fixing the issue ❤️

2.14.0

27 Sep 12:15
b919355

Choose a tag to compare

This version adds greaterThanOrEqual() and lessThanOrEqual(), with their respective aliases gte() and lte().

See #16 for details.

2.13.1

04 Jun 19:58
6051ebe

Choose a tag to compare

This version adds the possibility to specify the rounding method for multiply() and divide(), and also fixes a bug with the divideAndRound() function when the divisor is negative.

More details from @gidonkatten’s PR (see #13):

The default behaviour for the multiply and divide operations was to ROUND_HALF. Added the possibility to specify whether to ROUND_UP or ROUND_DOWN. Rounding down is especially important as that is the typical behaviour in smart contract opcodes (EVM and non-EVM alike).

Also fixed a bug in the divideAndRound function (which is called by many operations) when the divisor is negative. E.g. divideAndRound(-15n, 2n)) and divideAndRound(15n, -2n) yielded different results.

Thanks @gidonkatten 🙏

2.12.0

01 Apr 14:48
9b693cc

Choose a tag to compare

This version fixes the typing of toNumber() and toString() by allowing their second parameter to be optional, in line with their behavior and documentation.

See #12 for details.

Thanks @nbran 🙏

2.11.0

28 Jan 15:49
32fe9da

Choose a tag to compare

This version exports the Numberish type.

See #9 for details.

Thanks @desoss 🙏

2.10.0

05 Jan 15:59
266e81d

Choose a tag to compare

This version fixes an issue where projects using Node16 or NodeNext moduleResolution in their TypeScript projects were not able to resolve the types.

See #7 for details.

Thanks @ryangoree!

2.9.0

25 Sep 18:18
c78fc61

Choose a tag to compare

This version adds toString(), which works like toNumber():

let value = [123456789000000000000000n, 18];

toString(value); // "123456.789"
toString(value, 1); // "123456.8"

Thanks to @DannyDelott for suggesting this! 🙏

2.8.1

14 Sep 13:20
9059fc0

Choose a tag to compare

API changes:

Bug fixes:

  • Fixes an issue with the format() function where the sign was missing from negative numbers with a whole part equal to 0.

Internal changes:

  • formatSign(): (internal) returns a number sign.
  • toParts(): (internal) the whole part is now always positive. This is to make its behavior consistent: before this change, the sign was only removed when the value of the whole part was 0.