Mottie / javascript-number-formatter

Lightweight & Fast JavaScript Number Formatter
http://mottie.github.io/javascript-number-formatter/
MIT License
141 stars 37 forks source link

Remove trailing zeros for integer input OR improve documentation #19

Closed mingos777 closed 5 years ago

mingos777 commented 5 years ago

In #18 trailing zeroes were supposedly fixed, however, I am unable to understand how to remove them completely when the input value is an integer. Here's my case:

expect(format("# ###,#", 19.9, {})).to.equal("19,9"); // pass
expect(format("# ###,#", 20, {})).to.equal("20"); // fail; actual output: "20,0"

I assume I'm not asking for something that your tool cannot do, but the documentation fails to explain the formatting strings. I do not understand what the various symbols (# vs 0) mean and how to use them to achieve what I need.

Mottie commented 5 years ago

Hi @mingos777!

Thanks for reporting this problem. It was not behaving as expected. Version 2.0.7 was just released and will now behave as expected.

Mottie commented 5 years ago

Also, let me know if the new "format symbols" section in the readme is sufficient.

mingos777 commented 5 years ago

I have confirmed that version 2.0.7 behaves as expected. The new doc section makes formatting options clear, thank you very much!