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","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","getAmountWithSymbol","amount","options","formatter","Intl","NumberFormat","dayjs","locale","format","Number","currencyFormat","exports","withAmount","undefined","minimumFractionDigits","style","withSymbol","currency","withCode","concat","withSymbolAndCode"],"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,CAAA,EAAAC,CAAA,QAAAC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