BenjaminVanRyseghem / numbro

A JS library for number formatting
http://numbrojs.com
MIT License
1.1k stars 198 forks source link

Overriding currency symbol loses locale formatting #394

Open chopkins123 opened 5 years ago

chopkins123 commented 5 years ago

Some of the financial data we have has to be shown in $, even though a user locale can be set to something else. The formatCurrency method has a property currencySymbol that can be passed in to override the locale currency symbol, however when this is passed the rest of the locale formatting is lost. See example below:

numbro.setLanguage("da-DK");
console.log(numbro(6146692490).formatCurrency()); // 6,147 miakr
console.log(numbro(6146692490).formatCurrency({ currencySymbol: "$" })); //6146692490$
andi-dev commented 5 years ago

This seems to happen here: https://github.com/BenjaminVanRyseghem/numbro/blob/8d72513d597c0c777e432d16462ec96159cb5e0c/src/numbro.js#L46 <- once format options are passed to formatCurrency, those options are used instead of the default options. @BenjaminVanRyseghem what is the reason for not using Object.assign and merging them?