intl-format-cache

WebJar for intl-format-cache

Лицензия

Лицензия

BSD 3-Clause
Категории

Категории

ORM Данные
Группа

Группа

org.webjars.bowergithub.yahoo
Идентификатор

Идентификатор

intl-format-cache
Последняя версия

Последняя версия

2.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

intl-format-cache
WebJar for intl-format-cache
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/yahoo/intl-format-cache

Скачать intl-format-cache

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.yahoo/intl-format-cache/ -->
<dependency>
    <groupId>org.webjars.bowergithub.yahoo</groupId>
    <artifactId>intl-format-cache</artifactId>
    <version>2.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.yahoo/intl-format-cache/
implementation 'org.webjars.bowergithub.yahoo:intl-format-cache:2.1.0'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.yahoo/intl-format-cache/
implementation ("org.webjars.bowergithub.yahoo:intl-format-cache:2.1.0")
'org.webjars.bowergithub.yahoo:intl-format-cache:jar:2.1.0'
<dependency org="org.webjars.bowergithub.yahoo" name="intl-format-cache" rev="2.1.0">
  <artifact name="intl-format-cache" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.yahoo', module='intl-format-cache', version='2.1.0')
)
libraryDependencies += "org.webjars.bowergithub.yahoo" % "intl-format-cache" % "2.1.0"
[org.webjars.bowergithub.yahoo/intl-format-cache "2.1.0"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

This repo was migrated to the monorepo

Intl Format Cache

A memoizer factory for Intl format constructors.

npm Version Build Status Dependency Status

Overview

This is a helper package used within Yahoo's FormatJS suite. It provides a factory for creating memoizers of Intl format constructors: Intl.NumberFormat, Intl.DateTimeFormat, IntlMessageFormat, and IntlRelativeFormat.

Creating instances of these Intl formats is an expensive operation, and the APIs are designed such that developers should re-use format instances instead of always creating new ones. This package is simply to make it easier to create a cache of format instances of a particular type to aid in their reuse.

Under the hood, this package creates a cache key based on the arguments passed to the memoized constructor (it will even order the keys of the options argument) it uses JSON.stringify() to create the string key. If the runtime does not have built-in or polyfilled support for JSON, new instances will be created each time the memoizer function is called.

Usage

This package works as an ES6 or Node.js module, in either case it has a single default export function; e.g.:

// In an ES6 module.
import memoizeFormatConstructor from 'intl-format-cache';
// In Node.
var memoizeFormatConstructor = require('intl-format-cache');

This default export is a factory function which can be passed an Intl format constructor and it will return a memoizer that will create or reuse an Intl format instance and return it.

var getNumberFormat = memoizeFormatConstructor(Intl.NumberFormat);

var nf1 = getNumberFormat('en');
var nf2 = getNumberFormat('en');
var nf3 = getNumberFormat('fr');

console.log(nf1 === nf2); // => true
console.log(nf1 === nf3); // => false

console.log(nf1.format(1000)); // => "1,000"
console.log(nf3.format(1000)); // => "1 000"

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

org.webjars.bowergithub.yahoo

Yahoo

Yahoo is a Verizon Media brand. This organization is the home to many of the active open source projects published by engineers at Yahoo and Verizon Media.

Версии библиотеки

Версия
2.1.0