toFormat
toFormat copied to clipboard
toFormat not respecting 'rm' passed in
I expected it to just inherit from the Decimal config (unsure if the fact that it didn't is itself another bug) but even when I passed in a rm explicitly it ignored it.
Code samples of the problem (I'm running Decimal 10.2.0 and toFormat 2.0.0):
Decimal.set({'rounding': 6});
toFormat(Decimal);
n = new Decimal('1234.5');
n.toFormat()
Expected: 1,234
Result: 1,235
n.toFormat(0, rm=6)
Expected: 1,234
Result: 1,235
Let me know if there is anything I can do to help troubleshoot! Thank you!
I tried your code and the result is as expected:
const Decimal = require('decimal.js')
const toFormat = require('toformat');
const log = console.log;
Decimal.set({'rounding': 6});
toFormat(Decimal);
n = new Decimal('1234.5');
log(n.toFormat()); // "1,234.5"
log(n.toFormat(0, rm=6)); // "1,234"
Hmm. I'll try again today in a fresh file to see if maybe something else is interacting with it. Also this is happening client-side for me in Safari 13.1.2.