osrec / currencyformatter.js Goto Github PK
View Code? Open in Web Editor NEWA super simple currency formatting library
License: MIT License
A super simple currency formatting library
License: MIT License
The patterns do not behave as expected? When using #
, the number should not substitute a 0
in the price, unless it is used with #0
This is correct:
OSREC.CurrencyFormatter.format(0.45, {pattern: "#,##0.## !"})
>> "0.45 $"
Incorrect (?):
OSREC.CurrencyFormatter.format(0.45, {pattern: "#,##.## !"})
>> "0.45 $"
Expected:
>> ".45 $"
Incorrect (?):
OSREC.CurrencyFormatter.format(120, {pattern: "#,##0.##00 !"})
>> "120.0000 $"
Expected:
>> "120.00 $"
Incorrect (?):
OSREC.CurrencyFormatter.format(120, {pattern: "#,##0.## !"})
>> "120.00 $"
Expected:
>> "120 $"
Is this not what was planned for the patterns?
the error is in the line 1179, the var segment should be declare out of if statement. Otherwise the library crash because it is trying to get the length of undefined
For this case:
OSREC.CurrencyFormatter.parse('€ -99,50', { locale: 'it' });
The current behavior return:
-99.5
The expected behavior is:
Returns -99.50
Is there any way to do it?
currencyFormatter.js/currencyFormatter.js
Line 1275 in 6c67325
I get Invalid character - line 1275 character 49 in IE10
Hi,
Thanks for the great lib.
What's the reason HTML entities are being used for currency symbols? When rendering the CurrencyFormatter output in React/JSX this requires dangerouslySetInnerHTML, which is troublesome. Would you consider replacing the HTML entities with unicode characters? If so, I can make a pull request.
The Central Bank of Venezuela is carrying out a re-denomination of their local currency, with the entry into circulation of the BOLIVAR SOBERANO
, effective June 4 2018.
The alphabetic code needs to be updated from VEF
to VES
.
More details: https://www.currency-iso.org/dam/downloads/dl_currency_iso_amendment_166.pdf
Is there anyway to import this utlity in React? Like so:
import OSREC from 'currencyformatter.js';
Thanks for your help in #3.
Could you help update some versions that we can not find from npm(1.0.0
1.0.1
1.0.3
)?
Thanks!
So lets say my locale is it-it
and I enter in the input 99,99
I want to convert that to 99.99
as the db expects to store this value in en-us
Thanks for your great library. Easy and reliable.
I am trying to display
100 => $100 and not $100,00.
How to achieve it ?
Thanks.
Hi,
Thanks for the great library.
The last release supports RON as well, but this is not added in the documentation.
In some cases user don't want show symbol base on currency but I can't found anything setting for that. I saw you get default value on defaultSymbol if user don't setting symbol on here
currencyFormatter.js/currencyFormatter.js
Line 1072 in 66fae5e
Should Allow to specify text colour dynamic if negative value
I hesitate to even call this an issue, since I'm just asking for advice. For our app, I expanded the matches[ i ] assignment in formatAll to make sure the existing string was a number (otherwise, I get errors) and to make sure it got applied to input elements (i.e., has value, not textContent)
` for (var i = 0; i < matches.length; ++i) {
// handle, e.g., span, p, etc.
if (!(isNaN(matches[i].textContent))) {
var formattedString = formatter(matches[i].textContent);
matches[i].textContent = formattedString;
}
// handle inputs
if (!(isNaN(matches[i].value))) {
var formattedString = formatter(matches[i].value);
matches[i].value = formattedString;
}
}`
My two questions:
Hi,
i have a framework which covers Fiat and Crypto balances. Would it be possible to have a parameter which allowed you do edit the precision of the decimal? Some cryptos have 8 decimals and some 3, being able to show this and also remove the currency symbol would allow use across the board.
It will be cool if i could choose currencies what i need
not exactly the best issue title, but im not quite sure what to call this. i would like to prevent the numbers from scrolling/tallying/iterating (whatever one calls this) on the dom like they are doing in this gif. given that this isnt an async
func, how could i do this?
import 'currencyformatter.js'
Uncaught ReferenceError: OSREC is not defined
at Object. (custom.js:148)
at fire (jquery.js:3268)
at Object.fireWith [as resolveWith] (jquery.js:3398)
at done (jquery.js:9305)
at XMLHttpRequest. (jquery.js:9548)
Documentation states that I can pass custom symbol to the formatter, but it ignores an empty value.
I need to format only the number, without currency symbol. Currently it's impossible without extra code that strips non-numeric values from output.
According to ISO 4127, some currencies have a different number of decimal places than the usual 2 digits. For instance, the KRW has 0, while the BHD has 3.
Do you have plans to incorporate these quirks into this library/would you be open to a pull request that does so? Thanks!!
It would be nice if the script was installable through bower.
Is it possible to format a currency without adding the symbol? I know it is possible with custom formatting but if I have to customise the formatting for all locales my use of this library becomes pointless.
I'm trying to format user input inside an input field. If the symbol trails the value the UX is weird. Here is an example of the problem: https://codepen.io/fuzzyvagina/pen/MXGYaj
It would be great if passing null as symbol disabled the symbol:
OSREC.CurrencyFormatter.format(123456, { currency: 'ISK', symbol: null })
// output: 123.456 rather than 123.456 kr
Is there a reason for the library to convert
OSREC.CurrencyFormatter.format(0.999, { currency: 'EUR'})
shows "1,00 €"
Is there a reason for this rounding off, and also is there a way to avoid this rounding off ?
Hi, thanks for the library :)
I would like to know if you could transpile it to ES5. I'm getting an error because of this line:
currencyFormatter.js/currencyFormatter.js
Line 1262 in f85b991
That happens when I run webpack -p so UglifyJS breaks
I've added some changes to be able to use ES6 in this PR #15 in the future. Thanks :)
Hi all,
In Arab language we read from right to the left,
So for example if we want to read a price format in Saudi Arabian Riyal in arabic
it should be
number in the left and symbol in the right
I know that we can solve it in format parameter but I think it would be better to concern this fix in future releases
And Thank you!
Hi,
The format of the MXN is wrong, I fix this by changing:
es_MX: { h: 'es' },
To:
es_MX: { p: '!#,##0.00', g: ',', d: '.' },
In all js files.
I hope this can help.
Thank you,
Hi, what you think about pass currency and countries array to JSON. So the code goes be more legible, and javascript file will be smaller than now
I have the formatted price in the currency CVE
formatted price is 3,000,00 This price is formatted from the android device based on the selected locale.
I'm using the below code to parse the currency
var currency = require("currencyformatter.js");
console.log(currency.parse('3,000,00 ', { currency: 'CVE' } ));
The above code gives NaN.
i keep getting :
ReferenceError: OSREC is not defined
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.