Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@formatjs/intl-numberformat
Advanced tools
@formatjs/intl-numberformat is a JavaScript library that provides a robust and flexible way to format numbers according to different locales and formatting options. It leverages the ECMAScript Internationalization API (Intl) to offer a wide range of number formatting capabilities, including currency, percentages, and custom number formats.
Basic Number Formatting
This feature allows you to format numbers according to a specified locale. In this example, the number 1234567.89 is formatted according to the 'en-US' locale.
const { NumberFormat } = require('@formatjs/intl-numberformat');
const formatter = new NumberFormat('en-US');
console.log(formatter.format(1234567.89)); // Output: 1,234,567.89
Currency Formatting
This feature allows you to format numbers as currency. In this example, the number 1234567.89 is formatted as USD currency according to the 'en-US' locale.
const { NumberFormat } = require('@formatjs/intl-numberformat');
const formatter = new NumberFormat('en-US', { style: 'currency', currency: 'USD' });
console.log(formatter.format(1234567.89)); // Output: $1,234,567.89
Percentage Formatting
This feature allows you to format numbers as percentages. In this example, the number 0.1234 is formatted as a percentage according to the 'en-US' locale.
const { NumberFormat } = require('@formatjs/intl-numberformat');
const formatter = new NumberFormat('en-US', { style: 'percent' });
console.log(formatter.format(0.1234)); // Output: 12%
Custom Number Formatting
This feature allows you to customize the number of fraction digits. In this example, the number 1234567.89 is formatted to always show two decimal places according to the 'en-US' locale.
const { NumberFormat } = require('@formatjs/intl-numberformat');
const formatter = new NumberFormat('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
console.log(formatter.format(1234567.89)); // Output: 1,234,567.89
Numeral.js is a library for formatting and manipulating numbers. It provides a wide range of formatting options, including currency, percentages, and custom formats. Unlike @formatjs/intl-numberformat, Numeral.js does not rely on the Intl API and offers its own set of formatting rules.
Accounting.js is a lightweight JavaScript library for number, money, and currency formatting. It is designed to be simple and easy to use, with a focus on financial calculations. While it offers similar functionalities to @formatjs/intl-numberformat, it is more specialized for accounting purposes.
Numbro.js is a JavaScript library for formatting and manipulating numbers. It supports a wide range of locales and provides features for currency, percentages, and custom number formats. Numbro.js is similar to @formatjs/intl-numberformat but offers additional features like parsing and unformatting numbers.
intl-numberformat
We've migrated the docs to https://formatjs.io/docs/polyfills/intl-numberformat.
FAQs
Ponyfill for ES2020 Intl.NumberFormat
The npm package @formatjs/intl-numberformat receives a total of 65,661 weekly downloads. As such, @formatjs/intl-numberformat popularity was classified as popular.
We found that @formatjs/intl-numberformat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.