Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toFormat not respecting 'rm' passed in #5

Open
juviasuisei opened this issue Sep 2, 2020 · 2 comments
Open

toFormat not respecting 'rm' passed in #5

juviasuisei opened this issue Sep 2, 2020 · 2 comments

Comments

@juviasuisei
Copy link

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!

@MikeMcl
Copy link
Owner

MikeMcl commented Sep 3, 2020

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"

@juviasuisei
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants