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

allow a decimal format for an integer #222

Merged

Conversation

@mguida22
Copy link
Contributor

@mguida22 mguida22 commented Oct 12, 2016

From #199, when using a decimal format with a wildcard, on an integer, numbro gives an error

numbro(-40).format('#.*');

numbro.js:643 Uncaught TypeError: Cannot read property 'length' of undefined

This addresses the issue by checking for a decimal before attempting to format it. The same line from above will now return '-40'

numbro.js Outdated
@@ -658,7 +661,7 @@

w = d.split('.')[0];

if (d.split('.')[1].length) {
if (d.split('.').length > 1 && d.split('.')[1].length) {

This comment has been minimized.

@msaglietto

msaglietto Nov 8, 2016

mm in here you are doing the split like 4 times .. maybe its better to save the result of the split and then use it

This comment has been minimized.

@BenjaminVanRyseghem

BenjaminVanRyseghem Nov 8, 2016
Owner

sounds like a good idea 😄

don't error when an integer is formatted as a decimal with a wildcard.

ex:
`numbro(-40).format('#.*');` will now return `'-40'`

fixes #199, see for more context
@mguida22 mguida22 force-pushed the mguida22:decimal-format branch from b1b3669 to 086c7bc Nov 9, 2016
@msaglietto
Copy link

@msaglietto msaglietto commented Nov 14, 2016

THanks @mguida22 I think it looks ok now .. what do you think @BenjaminVanRyseghem could we merge this .. I could use it =P ...

@BenjaminVanRyseghem
Copy link
Owner

@BenjaminVanRyseghem BenjaminVanRyseghem commented Nov 14, 2016

thanks 👍

@BenjaminVanRyseghem BenjaminVanRyseghem merged commit 5fa21b0 into BenjaminVanRyseghem:develop Nov 14, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@mguida22
Copy link
Contributor Author

@mguida22 mguida22 commented Nov 14, 2016

Thanks for the feedback on this!

@BenjaminVanRyseghem
Copy link
Owner

@BenjaminVanRyseghem BenjaminVanRyseghem commented Mar 27, 2017

in numbro 1.10.0

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

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.