JSPM

currencyutility

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q21610F
  • License ISC

indian and international currency format representation

Package Exports

  • currencyutility

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (currencyutility) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Currency Utility

This package can be used to correctly represent monetary values in Indian and International Format.

The values are comma separated on the basis of format specified.

Formats Availability

Currently there are 2 formats supported by the package

  • IndianFormat - last comma at 3 digits and subsequently after 2 digits from the right
    • example : ₹ 1,00,000 ,₹ 1,00,00,000
  • InternationalFormat - Comma subsequently after 3 digits from the right
    • example : $ 1,000,000 , $ 1,000,000,000

Usage

getFormattedCurrencyString(value,format)

returns a string with currency symbol and comma representaion
const currencyUtility = require('currencyutility');
const formats = require('currencyutility/CurrencyFormats');

let indianFormatRepresentation = 
currencyUtility.getFormattedCurrencyString(1500000,formats.IndianFormat);  // 15 lakh

console.log(indianFormatRepresentation);   // Outputs:  ₹ 15,00,000

let internationalFormatRepresentation = 
currencyUtility.getFormattedCurrencyString(1500000,formats.InternationalFormat)  // 1.5 million

console.log(internationalFormatRepresentation); // Outputs: $ 1,500,000