Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@poppinss/intl-formatter
Advanced tools
JavaScript Internationalization API, memoized for speed and performance
JavaScript Internationalization API, memoized for speed and performance
The @poppinss/intl-formatter
package ships with the memoized version of the Intl
API. Creating new instances of the new Intl.<AnyFormatter>
is painfully slow (see benchmarks), and this package caches those instances for re-use.
new Intl.DateTimeFormat()
, you write formatters.date()
, and the rest is all the same.Install the package from the npm registry as follows:
npm i @poppinss/intl-formatter
# Yarn friends
yarn add @poppinss/intl-formatter
And use it as follows:
import formatters from '@poppinss/intl-formatter'
const amount = formatters
.number('en-in', { style: 'currency', currency: 'INR' })
.format(10)
console.log(amount)
formatters.number
same as Intl.NumberFormatformatters.date
same as Intl.DateTimeFormatformatters.relative
same as Intl.RelativeTimeFormatformatters.plural
same as Intl.PluralRulesformatters.list
same as Intl.ListFormatformatters.displayNames
same as Intl.DisplayNamesFormatJS is a great and popular library for Internationalization. However, it has a large set of polyfills for different platforms (especially for browsers) that do not have complete support for Intl.
This package relies on the native Intl APIs available in Node.js runtime and caches the instances for re-use and performance.
DateTimeFormat
DateTimeFormat@memoize x 2,192,264 ops/sec ±0.17% (99 runs sampled)
DateTimeFormat x 41,933 ops/sec ±16.93% (87 runs sampled)
Fastest is DateTimeFormat@memoize
NumberFormat
NumberFormat@memoize x 3,630,725 ops/sec ±0.87% (97 runs sampled)
NumberFormat x 88,994 ops/sec ±2.96% (93 runs sampled)
Fastest is NumberFormat@memoize
PluralRules
PluralRules@memoize x 3,296,162 ops/sec ±1.13% (98 runs sampled)
PluralRules x 80,256 ops/sec ±3.65% (82 runs sampled)
Fastest is PluralRules@memoize
RelativeTimeFormat
RelativeTimeFormat@memoize x 3,149,774 ops/sec ±1.07% (97 runs sampled)
RelativeTimeFormat x 114,421 ops/sec ±2.62% (90 runs sampled)
Fastest is RelativeTimeFormat@memoize
ListFormat
ListFormat@memoize x 1,875,493 ops/sec ±1.95% (95 runs sampled)
ListFormat x 311,985 ops/sec ±1.30% (96 runs sampled)
Fastest is ListFormat@memoize
DisplayNames
DisplayNames@memoize x 338,991 ops/sec ±0.96% (97 runs sampled)
DisplayNames x 128,909 ops/sec ±1.16% (94 runs sampled)
Fastest is DisplayNames@memoize
FAQs
JavaScript Internationalization API, memoized for speed and performance
The npm package @poppinss/intl-formatter receives a total of 3,911 weekly downloads. As such, @poppinss/intl-formatter popularity was classified as popular.
We found that @poppinss/intl-formatter 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.