META-INF.resources.bower_components.globalize.src.currency.supplemental-override.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-globalize Show documentation
Show all versions of jwebmp-globalize Show documentation
The JWebSwing implementation for a full Globalization
The newest version!
define([
"../util/string/pad"
], function (stringPad) {
/**
* supplementalOverride( currency, pattern, cldr )
*
* Return pattern with fraction digits overriden by supplemental currency data.
*/
return function (currency, pattern, cldr) {
var digits,
fraction = "",
fractionData = cldr.supplemental(["currencyData/fractions", currency]) ||
cldr.supplemental("currencyData/fractions/DEFAULT");
digits = +fractionData._digits;
if (digits) {
fraction = "." + stringPad("0", digits).slice(0, -1) + fractionData._rounding;
}
return pattern.replace(/\.(#+|0*[0-9]|0+[0-9]?)/g, fraction);
};
});