Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
simple-currency-format
Advanced tools
IF you do not have access to Javascript Intl library.
Like when you are running on Android with React Native.
Then your can use this simplified formatter.
It is simplified in a way that it will always return the same currency symbols for any given currency code.
Even when a locale that should render a specific other symbol is used.
This library simply use the symbol that is used in the prefered currency in a locale.
npm install simple-currency-format
yarn add simple-currency-format
Parameters:
amount: number
, The number to format
locale: string
, The locale for the format (i.e. de-DE, en-US,en-GB )
currency: string
, Currency code (i.e. EUR, USD, GBP)
decimals: number
, Number of decimals (default: 0)
Returns: string
, Formatted currency
import { currencyFormat } from 'simple-currency-format';
console.log(currencyFormat(1000000, 'sv-SE', 'SEK'));
// 1 000 000 kr
console.log(currencyFormat(1000000, 'en-GB', 'GBP'));
// £1,000,000
console.log(currencyFormat(1000000, 'mt-MT', 'EUR'));
// €1,000,000
console.log(currencyFormat(1000000, 'de-DE', 'EUR'));
// 1.000.000 €
console.log(currencyFormat(1000000, 'en-US', 'USD'));
// $1, 000, 000;
Parameters:
currency: string
, Currency code (i.e. EUR, USD, GBP)
Returns: string
, Currency symbol (i.e. kr, £)
import { getCurrencySymbol } from 'simple-currency-format';
console.log(getCurrencySymbol('SEK'));
// kr;
console.log(getCurrencySymbol('GBP'));
// £;
FAQs
Format currency when Intl is not available
The npm package simple-currency-format receives a total of 4,799 weekly downloads. As such, simple-currency-format popularity was classified as popular.
We found that simple-currency-format demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.