UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

43 lines (42 loc) 1.42 kB
/** * DevExtreme (localization/open_xml_currency_format.js) * Version: 20.1.7 * Build date: Tue Aug 25 2020 * * Copyright (c) 2012 - 2020 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; module.exports = function(currencySymbol, accountingFormat) { if (!accountingFormat) { return } var encodedCurrencySymbol = currencySymbol; if ("string" === typeof currencySymbol) { encodedCurrencySymbol = ""; for (var i = 0; i < currencySymbol.length; i++) { if ("$" !== currencySymbol[i]) { encodedCurrencySymbol += "\\" } encodedCurrencySymbol += currencySymbol[i] } } var encodeSymbols = { ".00": "{0}", "'": "\\'", "\\(": "\\(", "\\)": "\\)", " ": "\\ ", '"': "&quot;", "\\\xa4": encodedCurrencySymbol }; var result = accountingFormat.split(";"); for (var _i = 0; _i < result.length; _i++) { for (var symbol in encodeSymbols) { if (Object.prototype.hasOwnProperty.call(encodeSymbols, symbol)) { result[_i] = result[_i].replace(new RegExp(symbol, "g"), encodeSymbols[symbol]) } } } return 2 === result.length ? result[0] + "_);" + result[1] : result[0] };