New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

js-currency-format

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-currency-format

This is a tool for intl currency and percent formatting.the special feature is that it can be uesd in event listenner function onChange of inputNumber

latest
npmnpm
Version
1.0.3
Version published
Weekly downloads
23
Maintainers
1
Weekly downloads
 
Created
Source

intl currency format

this is a tool that can format and unformat currency and percent.the special feature is that it can be uesd in event listenner function onChange of inputNumber;

install

npm i js-currency-format

usage

import CurrencyFormatter from 'js-currency-format';

const currencyFormatter = new CurrencyFormatter({
  locales: 'zh-CN',
  precision: 5,
  currency: 'USD',
  style: 'currency',
  // currencyDisplay: 'code'
});

const b = a.format(10000);
console.log(b);
console.log(a.unformat(b));

if you want to know more details of values from format and unformat, you can see file 'test/index.test.ts';

api

  • CurrencyFormatter.prototype.parseThousandthsSymbol: (locales?: string | string[]) => string: it can get thousandths symbol form the locales
  • CurrencyFormatter.prototype.parseDecimalSymbol: (locales?: string | string[]) => string: it can get decimal symbol form the locales
  • CurrencyFormatter.prototype.parseStyleSymbol(options?: CurrencyFormatterProps) => [styleSymbolPosition, string]: it can get style symbol form the CurrencyFormatterProps
  • CurrencyFormatter.prototype.format: (formatVal: number | string, localesOrOption?: string | string[], options?: CurrencyFormatterProps) => string
  • CurrencyFormatter.prototype.unformat: (string: number | string, locales?: string | string[], options?: CurrencyFormatterProps & {isNumber: boolean}) => number | string

arguments

Number.prototype.toLocaleString.Maybe you can get some informations from this page of MDN;

// constructor
interface CurrencyFormatterProps {
  locales: string | string[],
  minimumIntegerDigits?: number,
  precision?: number,
  useGrouping?: boolean,
  localeMatcher?: 'lookup' | 'best fit',
  formatter?: typeof CurrencyFormatter.formatter,

  style?: 'decimal' | 'currency' | 'percent',
  currency?: string,
  currencyDisplay?: 'symbol' | 'code' | 'name',
}

//options of format
interface optionsofformat {
  minimumIntegerDigits?: number,
  precision?: number,
  useGrouping?: boolean,
  localeMatcher?: 'lookup' | 'best fit',

  style?: 'decimal' | 'currency' | 'percent',
  currency?: string,
  currencyDisplay?: 'symbol' | 'code' | 'name',
}

Keywords

currency format

FAQs

Package last updated on 18 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts