Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@poppinss/intl-formatter
Advanced tools
Memoized API for Intl (To be used within Node.js)
The 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 1,115,507 ops/sec ±0.22% (94 runs sampled)
DateTimeFormat x 20,042 ops/sec ±20.76% (75 runs sampled)
Fastest is DateTimeFormat@memoize
NumberFormat
NumberFormat@memoize x 2,874,842 ops/sec ±0.28% (97 runs sampled)
NumberFormat x 74,720 ops/sec ±1.14% (97 runs sampled)
Fastest is NumberFormat@memoize
PluralRules
PluralRules@memoize x 2,381,739 ops/sec ±0.63% (97 runs sampled)
PluralRules x 62,113 ops/sec ±2.88% (91 runs sampled)
Fastest is PluralRules@memoize
RelativeTimeFormat
RelativeTimeFormat@memoize x 2,426,178 ops/sec ±1.11% (92 runs sampled)
RelativeTimeFormat x 89,485 ops/sec ±3.48% (84 runs sampled)
Fastest is RelativeTimeFormat@memoize
ListFormat
ListFormat@memoize x 1,501,976 ops/sec ±1.94% (97 runs sampled)
ListFormat x 244,943 ops/sec ±0.93% (97 runs sampled)
Fastest is ListFormat@memoize
DisplayNames
DisplayNames@memoize x 299,573 ops/sec ±0.56% (93 runs sampled)
DisplayNames x 106,279 ops/sec ±1.32% (94 runs sampled)
Fastest is DisplayNames@memoize
FAQs
JavaScript Internationalization API, memoized for speed and performance
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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.