package.cjs.utils.currencyFormat.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
{"version":3,"file":"currencyFormat.js","names":["_dayjs","_interopRequireDefault","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","getAmountWithSymbol","amount","options","formatter","Intl","NumberFormat","dayjs","locale","format","Number","currencyFormat","withAmount","undefined","minimumFractionDigits","style","withSymbol","currency","withCode","concat","withSymbolAndCode","exports"],"sources":["../../../src/utils/currencyFormat.js"],"sourcesContent":["import dayjs from \"dayjs\";\n\nconst getAmountWithSymbol = (amount, options) => {\n const formatter = new Intl.NumberFormat(dayjs.locale(), {\n ...options,\n });\n\n return formatter.format(Number(amount));\n};\n\nexport const currencyFormat = {\n withAmount: (amount, options = { minimumFractionDigits: 2 }) =>\n getAmountWithSymbol(amount, {\n style: undefined,\n ...options,\n }), // 1000, { maximumFractionDigits: 1 } => 1,000.0\n withSymbol: (amount, currency, options) =>\n getAmountWithSymbol(amount, {\n ...options,\n style: \"currency\",\n currency,\n }), // 1000, \"INR\", { maximumFractionDigits: 0 } => ₹1,000\n withCode: (amount, currency, options = { minimumFractionDigits: 2 }) =>\n `${getAmountWithSymbol(amount, {\n ...options,\n style: undefined,\n })} ${currency}`, // 1000, \"USD\" => 1,000.00 USD\n withSymbolAndCode: (amount, currency, options) =>\n `${getAmountWithSymbol(amount, {\n ...options,\n style: \"currency\",\n currency,\n })} ${currency}`, // 1000, \"INR\", { maximumFractionDigits: 0 } => ₹1,000 INR\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAC,QAAAC,MAAA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