Socket
Socket
Sign inDemoInstall

@formatjs/ecma402-abstract

Package Overview
Dependencies
2
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/ecma402-abstract


Version published
Maintainers
3
Created

Package description

What is @formatjs/ecma402-abstract?

@formatjs/ecma402-abstract is a library that provides abstract operations for the ECMAScript Internationalization API (ECMA-402). It is used to implement the low-level operations required for internationalization features such as formatting dates, numbers, and strings according to different locales.

What are @formatjs/ecma402-abstract's main functionalities?

DateTime Formatting

This feature allows you to format dates according to a specific locale. The code sample demonstrates how to format the current date in the 'en-US' locale with options for year, month, and day.

const { FormatDateTime } = require('@formatjs/ecma402-abstract');
const date = new Date();
const options = { year: 'numeric', month: 'long', day: 'numeric' };
const formattedDate = FormatDateTime('en-US', date, options);
console.log(formattedDate);

Number Formatting

This feature allows you to format numbers according to a specific locale. The code sample demonstrates how to format a number as a currency in the 'en-US' locale.

const { FormatNumber } = require('@formatjs/ecma402-abstract');
const number = 1234567.89;
const options = { style: 'currency', currency: 'USD' };
const formattedNumber = FormatNumber('en-US', number, options);
console.log(formattedNumber);

String Collation

This feature allows you to compare strings according to a specific locale. The code sample demonstrates how to compare two strings in the 'en-US' locale.

const { CompareStrings } = require('@formatjs/ecma402-abstract');
const str1 = 'apple';
const str2 = 'banana';
const comparison = CompareStrings('en-US', str1, str2);
console.log(comparison);

Other packages similar to @formatjs/ecma402-abstract

Readme

Source

ECMA402 Abstract

Implementation for various ECMAScript 402 abstract operations.

npm Version

IMPORTANT: This does not follow semver so please pin the version to the exact one that you need.

Keywords

FAQs

Last updated on 29 Nov 2022

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc