{"id":13881068,"url":"https://github.com/formatjs/intl-format-cache","last_synced_at":"2025-07-16T17:31:41.557Z","repository":{"id":19713774,"uuid":"22969264","full_name":"formatjs/intl-format-cache","owner":"formatjs","description":"Produces instances of JavaScript `Intl` formats, and caches them for reuse.","archived":true,"fork":false,"pushed_at":"2019-05-26T04:43:33.000Z","size":58,"stargazers_count":55,"open_issues_count":0,"forks_count":12,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-07-03T03:32:10.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://formatjs.io/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/formatjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-14T21:29:55.000Z","updated_at":"2024-07-26T12:02:40.000Z","dependencies_parsed_at":"2022-09-06T05:21:16.882Z","dependency_job_id":null,"html_url":"https://github.com/formatjs/intl-format-cache","commit_stats":null,"previous_names":["yahoo/intl-format-cache"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/formatjs/intl-format-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formatjs%2Fintl-format-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formatjs%2Fintl-format-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formatjs%2Fintl-format-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formatjs%2Fintl-format-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/formatjs","download_url":"https://codeload.github.com/formatjs/intl-format-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/formatjs%2Fintl-format-cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264091542,"owners_count":23556119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:03:58.090Z","updated_at":"2025-07-16T17:31:39.584Z","avatar_url":"https://github.com/formatjs.png","language":"TypeScript","readme":"# This repo was migrated to the [monorepo](https://github.com/formatjs/formatjs/tree/master/packages/intl-locales-supported)\n\n\nIntl Format Cache\n=================\n\nA memoizer factory for Intl format constructors.\n\n[![npm Version][npm-badge]][npm]\n[![Build Status][travis-badge]][travis]\n[![Dependency Status][david-badge]][david]\n\n\nOverview\n--------\n\nThis is a helper package used within [Yahoo's FormatJS suite][FormatJS]. It provides a factory for creating memoizers of [`Intl`][Intl] format constructors: [`Intl.NumberFormat`][Intl-NF], [`Intl.DateTimeFormat`][Intl-DTF], [`IntlMessageFormat`][Intl-MF], and [`IntlRelativeFormat`][Intl-RF].\n\nCreating 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.\n\nUnder 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.\n\n\nUsage\n-----\n\nThis package works as an ES6 or Node.js module, in either case it has a single default export function; e.g.:\n\n```js\n// In an ES6 module.\nimport memoizeFormatConstructor from 'intl-format-cache';\n```\n\n```js\n// In Node.\nvar memoizeFormatConstructor = require('intl-format-cache');\n```\n\nThis 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.\n\n```js\nvar getNumberFormat = memoizeFormatConstructor(Intl.NumberFormat);\n\nvar nf1 = getNumberFormat('en');\nvar nf2 = getNumberFormat('en');\nvar nf3 = getNumberFormat('fr');\n\nconsole.log(nf1 === nf2); // =\u003e true\nconsole.log(nf1 === nf3); // =\u003e false\n\nconsole.log(nf1.format(1000)); // =\u003e \"1,000\"\nconsole.log(nf3.format(1000)); // =\u003e \"1 000\"\n```\n\n\nLicense\n-------\n\nThis software is free to use under the Yahoo! Inc. BSD license.\nSee the [LICENSE file][LICENSE] for license text and copyright information.\n\n\n[npm]: https://www.npmjs.org/package/intl-format-cache\n[npm-badge]: https://img.shields.io/npm/v/intl-format-cache.svg?style=flat-square\n[david]: https://david-dm.org/formatjs/intl-format-cache\n[david-badge]: https://img.shields.io/david/formatjs/intl-format-cache.svg?style=flat-square\n[travis]: https://travis-ci.org/formatjs/intl-format-cache\n[travis-badge]: https://img.shields.io/travis/formatjs/intl-format-cache/master.svg?style=flat-square\n[Intl]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl\n[Intl-NF]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat\n[Intl-DTF]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat\n[Intl-MF]: https://github.com/formatjs/formatjs\n[Intl-RF]: https://github.com/formatjs/intl-relativeformat\n[FormatJS]: http://formatjs.io/\n[LICENSE]: https://github.com/formatjs/intl-format-cache/blob/master/LICENSE\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformatjs%2Fintl-format-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fformatjs%2Fintl-format-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fformatjs%2Fintl-format-cache/lists"}