Socket
Socket
Sign inDemoInstall

@formatjs/intl-unified-numberformat

Package Overview
Dependencies
1
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @formatjs/intl-unified-numberformat

Ponyfill for intl unified numberformat proposal


Version published
Weekly downloads
183K
decreased by-15.92%
Maintainers
3
Created
Weekly downloads
 

Package description

What is @formatjs/intl-unified-numberformat?

@formatjs/intl-unified-numberformat is a polyfill for the ECMAScript Internationalization API's Unified NumberFormat, which provides a way to format numbers in a locale-sensitive manner. This package is particularly useful for applications that need to support multiple locales and require consistent number formatting across different environments.

What are @formatjs/intl-unified-numberformat's main functionalities?

Basic Number Formatting

This feature allows you to format numbers according to the locale specified. In this example, the number 1234567.89 is formatted according to the 'en-US' locale.

const UnifiedNumberFormat = require('@formatjs/intl-unified-numberformat');
const formatter = new UnifiedNumberFormat('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 UnifiedNumberFormat = require('@formatjs/intl-unified-numberformat');
const formatter = new UnifiedNumberFormat('en-US', { style: 'currency', currency: 'USD' });
console.log(formatter.format(1234567.89)); // Output: $1,234,567.89

Percent 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 UnifiedNumberFormat = require('@formatjs/intl-unified-numberformat');
const formatter = new UnifiedNumberFormat('en-US', { style: 'percent' });
console.log(formatter.format(0.1234)); // Output: 12%

Unit Formatting

This feature allows you to format numbers with units. In this example, the number 60 is formatted as miles per hour according to the 'en-US' locale.

const UnifiedNumberFormat = require('@formatjs/intl-unified-numberformat');
const formatter = new UnifiedNumberFormat('en-US', { style: 'unit', unit: 'mile-per-hour' });
console.log(formatter.format(60)); // Output: 60 mph

Other packages similar to @formatjs/intl-unified-numberformat

Readme

Source

intl-unified-numberformat

We've migrated the docs to https://formatjs.io.

Keywords

FAQs

Last updated on 16 May 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc