{"name":"intl-format-cache","version":"2.2.0","description":"A memoizer factory for Intl format constructors.","main":"index.js","module":"lib/index.js","typings":"lib/index.d.ts","scripts":{"build":"tsc -p src && tsc -p src/tsconfig.cjs.json","clean":"rimraf lib dist","cover":"nyc npm t","prepublishOnly":"npm run clean && npm run build","prettier":"prettier --write {src,tests}/*.ts","test":"TS_NODE_PROJECT='tests/tsconfig.json' mocha -r ts-node/register -r source-map-support/register -r chai/register-expect tests/index.ts --reporter spec"},"repository":{"type":"git","url":"git+https://github.com/yahoo/intl-format-cache.git"},"keywords":["intl","i18n"],"author":{"name":"Eric Ferraiuolo","email":"eferraiuolo@gmail.com"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/yahoo/intl-format-cache/issues"},"homepage":"https://github.com/yahoo/intl-format-cache","dependencies":{},"devDependencies":{"@types/chai":"^4.1.7","@types/mocha":"^5.2.6","chai":"^4.2.0","intl":"^1.0.1","intl-messageformat":"3","intl-relativeformat":"^2.1.0","mocha":"^6.1.0","nyc":"^14.1.1","prettier":"^1.17.1","rimraf":"^2.6.3","source-map-support":"^0.5.12","ts-node":"^8.2.0","typescript":"^3.4.5"},"prettier":{"singleQuote":true},"gitHead":"a2403af7a1ec6045556426babee75d0f76615128","_id":"intl-format-cache@2.2.0","_nodeVersion":"10.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-JUKPBxip3H51+ycvI0uF2Wriamd4RMNIDVvkkt4WxsdHv/0kunc1o196VAVtLAju3/tcxdB0YVso0qPchZ9yEw==","shasum":"0aea2e73587f84a9c485a53b01c0f64884415884","tarball":"http://registry-npm.ywwl.com/intl-format-cache/download/intl-format-cache-2.2.0.tgz","fileCount":17,"unpackedSize":25597,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc6hFmCRA9TVsSAnZWagAANpQP/jwJn1uLPS0+C7jjCmT1\ncbot0f6IY2HHzzuM6flYF3loEVCavqi5jCibqZozMpZKL0NV7KLOM1op/t/y\ntixkvLw6oeemOMkdmFrfKD1eDGMraHw6/f3vlxjFD9xy5PMHyyas9BxTzBSN\nGeEhfGQut4guVpcFJqmUTE1Ka6WMXiv8ONMqs8cFDevlhu1jI5LU9epaR4jg\nUBNCXVR4Oo/yICZFUfAp/N/bYIinbI5KX9TYTh9v8HyaNPUGmRoS6p18+nuq\nuN8zOXDUmtFmJ9SPpOwLQzrb2qpBa51r4wkQMNS4IWdk9wZVoPqv9MSOlpNP\noIZ/NShZMooaQpotuQ86lpziLayxWfVLX9mlH04SkGr6h4gXjvQ4H6BNAFn7\ncsSVpcmk8WK60Ond9e3iRdBHhlqeNfzpHTfoaxVrS6dT45WqUdoEFXykyIY8\nngxXPwDiPIEt572NwsB83/Ey07teQPGbuBC9nSd82Xb/NvYovTZ2hMTraC7b\nIEGlPE3WR+iar6XypB4xWYP9NPTciCEV0Gdol8ixAqY00JKKu8VumaQMcaxm\n6hGwekCo2L6pNhE7MLkOXvD316xpvt3gmGzopS7MOxUaTjbuCzHEKPGrECMT\nvYWDlLWB0n5hYse4O7eiXd+WBIOzeKuviFP9Nak8IZHHnSSQhNMjU9eUL7OU\nQZSy\r\n=ODOF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvUwV+Pzja0m1ik91cEWQibC2IChckP/xA3XwR4K/qywIgeZjIEAqLzDgeHax8/LAOnyW/5eCu3iEyYRXPUuWCkhE="}],"size":6882,"noattachment":false,"key":"/intl-format-cache/-/intl-format-cache-2.2.0.tgz"},"maintainers":[{"name":"caridy","email":"caridy@gmail.com"},{"name":"ericf","email":"eferraiuolo@gmail.com"},{"name":"okuryu","email":"okuryu@okuryu.com"},{"name":"redonkulus","email":"seth@bertalotto.net"}],"_npmUser":{"name":"longlho","email":"holevietlong@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/intl-format-cache_2.2.0_1558843749457_0.20921211768262182"},"_hasShrinkwrap":false,"readme":"# Intl Format Cache\n\nA memoizer factory for Intl format constructors.\n\n[![npm Version][npm-badge]][npm]\n![size](https://badgen.net/bundlephobia/minzip/intl-format-cache)\n\n## Overview\n\nThis is a helper package used within [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.\n\n## Usage\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); // => true\nconsole.log(nf1 === nf3); // => false\n\nconsole.log(nf1.format(1000)); // => \"1,000\"\nconsole.log(nf3.format(1000)); // => \"1 000\"\n```\n\n# Benchmark\n\n```\nfast-memoize x 19,610 ops/sec ±1.86% (73 runs sampled)\nintl-format-cache x 18,854 ops/sec ±4.95% (81 runs sampled)\n--- NumberFormat cache set: Fastest is fast-memoize,intl-format-cache ---\n\nfast-memoize x 1,051,977 ops/sec ±1.53% (89 runs sampled)\nintl-format-cache x 1,134,171 ops/sec ±1.19% (91 runs sampled)\nnot cached x 23,002 ops/sec ±2.23% (83 runs sampled)\n--- NumberFormat cache get: Fastest is intl-format-cache ---\n\nfast-memoize x 6,466 ops/sec ±6.56% (72 runs sampled)\nintl-format-cache x 7,384 ops/sec ±50.43% (64 runs sampled)\n--- DateTimeFormat cache set: Fastest is fast-memoize ---\n\nfast-memoize x 965,874 ops/sec ±17.87% (90 runs sampled)\nintl-format-cache x 1,048,234 ops/sec ±0.79% (89 runs sampled)\nnot cached x 13,543 ops/sec ±2.61% (85 runs sampled)\n--- DateTimeFormat cache get: Fastest is intl-format-cache ---\n\nfast-memoize x 72,531 ops/sec ±26.27% (79 runs sampled)\nintl-format-cache x 88,729 ops/sec ±0.51% (91 runs sampled)\n--- IntlMessageFormat cache set: Fastest is intl-format-cache ---\n\nfast-memoize x 665,420 ops/sec ±2.61% (90 runs sampled)\nintl-format-cache x 649,186 ops/sec ±2.19% (90 runs sampled)\nnot cached x 127,110 ops/sec ±0.35% (91 runs sampled)\n--- IntlMessageFormat cache get: Fastest is fast-memoize ---\n\nfast-memoize x 1,294,591 ops/sec ±1.10% (94 runs sampled)\nintl-format-cache x 1,905,746 ops/sec ±0.71% (91 runs sampled)\nnot cached x 152,118 ops/sec ±0.47% (94 runs sampled)\n--- IntlMessageFormat cache get simple arg: Fastest is intl-format-cache ---\n\nnumber x 536,024 ops/sec ±0.99% (86 runs sampled)\ndatetime x 397,275 ops/sec ±0.92% (90 runs sampled)\nmessageformat x 1,278,072 ops/sec ±1.31% (89 runs sampled)\n--- all formats: Fastest is messageformat ---\n\nnumber x 532,863 ops/sec ±0.79% (93 runs sampled)\ndatetime x 377,391 ops/sec ±1.11% (89 runs sampled)\nmessageformat x 709,020 ops/sec ±3.19% (81 runs sampled)\n--- all formats random input: Fastest is messageformat ---\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[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/formatjs\n[formatjs]: http://formatjs.io/\n","publish_time":1558843749582,"_cnpm_publish_time":1558843749582,"dist-tags":{"latest":"4.3.1","next":"4.2.48-alpha.0"}}