package.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","getAmountWithSymbol","amount","options","formatter","Intl","NumberFormat","locale","_objectSpread","format","Number","currencyFormat","withAmount","arguments","length","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,OAAOA,KAAK,MAAM,OAAO;AAEzB,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,MAAM,EAAEC,OAAO,EAAK;EAC/C,IAAMC,SAAS,GAAG,IAAIC,IAAI,CAACC,YAAY,CAACN,KAAK,CAACO,MAAM,CAAC,CAAC,EAAAC,aAAA,KACjDL,OAAO,CACX,CAAC;EAEF,OAAOC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