{"name":"intl-pluralrules","version":"1.1.2","description":"Intl.PluralRules polyfill","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","homepage":"https://github.com/eemeli/intl-pluralrules#readme","repository":{"type":"git","url":"git+https://github.com/eemeli/intl-pluralrules.git"},"main":"polyfill","jest":{"collectCoverage":true,"moduleFileExtensions":["mjs","js","json"],"testMatch":["**/*.test.mjs"],"transform":{"\\.mjs$":"babel-jest"},"transformIgnorePatterns":[]},"prettier":{"semi":false,"singleQuote":true},"dependencies":{"make-plural":"^6.1.0"},"devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.8.7","@babel/preset-env":"^7.8.7","babel-jest":"^25.1.0","jest":"^25.1.0"},"scripts":{"build:cjs":"TARGET=cjs babel -d . src/ --ignore '**/*.test.mjs'","build:mjs":"babel -d . src/ --ignore '**/*.test.mjs' --keep-file-extension","build":"npm run build:mjs && npm run build:cjs","clean":"git clean -fdxe node_modules -e examples/node_modules","prepublishOnly":"npm test && npm run build","test":"jest"},"gitHead":"575ba0aeabce01d2d9ff626f09649dc96979f2f4","bugs":{"url":"https://github.com/eemeli/intl-pluralrules/issues"},"_id":"intl-pluralrules@1.1.2","_nodeVersion":"13.10.1","_npmVersion":"6.14.2","dist":{"integrity":"sha512-awT+Y/f7ftsg8IUfxRotCYFnDdmpFJQqud1jkOw8RAOUjslbhSC+xJoG4pqj/X8casKgAlQttnsbQP3R0BICyQ==","shasum":"0b5cd83001792b5088140f8bb5505c9f2d580277","tarball":"http://registry-npm.ywwl.com/intl-pluralrules/download/intl-pluralrules-1.1.2.tgz","fileCount":12,"unpackedSize":26933,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZObwCRA9TVsSAnZWagAA3PcP/j/B+KYTkpBxF1QQCazr\nMrHqDeIV82JS4fmkkUZGv7HXcQ+3t6PFWJ09A1TJ3gubHtMG1TFUsBlyijGQ\n+WB47Kx7z4byqBSTJlgjgVFjCYu83Asb3+w8dXAhI0loSR/nzGdLIDRmW3tl\nL64ciIUi1G13tHHeFhpQfYh79QcfFb/3rLzxhs2kKJ+Ik9l0kycwvDW5Wurs\nSrE8ifiNBdXx3V2BUe1Cp+j53k7ARakZnIzmk9tIfSUZ3kjOLpBEMA1X+d0u\nz5a/EPTZHLOJeqlRlzPUY7aARtRhH9g4hSq95uqkY2AEuX0jMWae8fE5jbQU\nPy85nJSXU+jRF2KDl2hdkLKXt0iN04VpxwJ7b/wAiiLDLMqELXczkK/mySsz\n1bY7oYYXKH+4Pfg8iYhUimUz6SsMoU6ecQSGesilG8/Jxaq/4mdCPYAJl4x3\nZudAJPXsV2qvkB70N+AaFcXu+thu9lLtoGu/tc0V+4o0TeaPI2Jglz29r4zO\n+ifAw5lKQTF2etAyHypHHMlOjXtsZ0OZl0LWDpSq8DRrd9ik5gdTVkzdwos2\niG5mQ3vGA5Lj1Cnfzz2ch9CYMcT3Ak252ieXIdbImoXOQmFs9Gn7mhsNpoCg\n+VOrTIcFF4DDZqC7EKCk8he9k2syYwOwbvU4QHrrHcT/dk/QzNY2h08O+WoN\nd4j9\r\n=Ydi6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuV7nRGG1+kRAJL3y43/UnZJ6uLsS8B+x8HnJGikxGaQIgXPWYUOtAYgupy2l2pQV/RRak2J4DBia8FfYGU0/sVG8="}],"size":6034,"noattachment":false,"key":"/intl-pluralrules/-/intl-pluralrules-1.1.2.tgz"},"maintainers":[{"name":"eemeli","email":"eemeli@gmail.com"}],"_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/intl-pluralrules_1.1.2_1583671024130_0.8204113166320675"},"_hasShrinkwrap":false,"readme":"# intl-pluralrules\n\nA spec-compliant implementation & polyfill for [Intl.PluralRules],\nincluding the `selectRange(start, end)` method introduced in [Intl.NumberFormat v3].\nAlso useful if you need proper support for [`minimumFractionDigits`],\nwhich are only supported in Chrome 77 & later.\n\nFor a polyfill without `selectRange()` and with IE 11 support, please use `intl-pluralrules@1`.\n\n[intl.pluralrules]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules\n[intl.numberformat v3]: https://github.com/tc39/proposal-intl-numberformat-v3/\n[`minimumfractiondigits`]: https://bugs.chromium.org/p/v8/issues/detail?id=8866\n\n## Installation\n\n```\nnpm install intl-pluralrules\n```\n\n## Polyfill\n\nTo use as a polyfill, just import it to ensure that `Intl.PluralRules` is\navailable in your environment:\n\n```js\nimport 'intl-pluralrules'\n```\n\nIf `Intl.PluralRules` already exists,\nincludes a `selectRange()` method,\nand supports [multiple locales](https://nodejs.org/api/intl.html),\nthe polyfill will not be loaded.\n\n## Ponyfill\n\nA complete implementation of PluralRules is available as\n`intl-pluralrules/plural-rules`, if you'd prefer using it without modifying your\n`Intl` object, or if you wish to use it rather than your environment's own:\n\n```js\nimport PluralRules from 'intl-pluralrules/plural-rules'\n\nnew PluralRules('en').select(1) // 'one'\nnew PluralRules('en', { minimumSignificantDigits: 3 }).select(1) // 'other'\nnew PluralRules('en').selectRange(0, 1) // 'other'\nnew PluralRules('fr').selectRange(0, 1) // 'one'\n```\n\n## Factory\n\nIn order to support all available locales, their data needs to be included in\nthe package. This means that when minified and gzipped, the above-documented\nusage adds about 7kB to your application's production size. If this is a\nconcern, you can use `intl-pluralrules/factory` and [make-plural] to build a\nPluralRules class with locale support limited to only what you actually use.\n\n[make-plural]: https://www.npmjs.com/package/make-plural\n\nThanks to tree-shaking, this example that only supports English and French\nminifies & gzips to 1472 bytes. Do note that this size difference is only\napparent with minified production builds.\n\n```js\nimport getPluralRules from 'intl-pluralrules/factory'\nimport { en, fr } from 'make-plural/plurals'\nimport { en as enCat, fr as frCat } from 'make-plural/pluralCategories'\nimport { en as enRange, fr as frRange } from 'make-plural/ranges'\n\nconst sel = { en, fr }\nconst getSelector = lc => sel[lc]\n\nconst cat = { en: enCat, fr: frCat }\nconst getCategories = (lc, ord) => cat[lc][ord ? 'ordinal' : 'cardinal']\n\nconst range = { en: enRange, fr: frRange }\nconst getRangeSelector = lc => range[lc]\n\nconst PluralRules = getPluralRules(\n  Intl.NumberFormat, // Not available in IE 10\n  getSelector,\n  getCategories,\n  getRangeSelector\n)\nexport default PluralRules\n```\n\nAll arguments of\n`getPluralRules(NumberFormat, getSelector, getCategories, getRangeSelector)`\nare required.\n\n- `NumberFormat` should be `Intl.NumberFormat`, or an implementation which\n  supports at least the `\"en\"` locale and all of the min/max digit count\n  options.\n- `getSelector(lc)` should return a `function(n, ord)` returning the plural\n  category of `n`, using cardinal plural rules (by default), or ordinal rules if\n  `ord` is true. `n` may be a number, or the formatted string representation of\n  a number. This may be called with any user-provided string `lc`, and should\n  return `undefined` for invalid or unsupported locales.\n- `getCategories(lc, ord)` should return the set of available plural categories\n  for the locale, either for cardinals (by default), or ordinals if `ord` is\n  true. This function will be called only with values for which `getSelector`\n  returns a function.\n- `getRangeSelector(lc)` should return a `function(start, end)` returning the\n  plural category of the range. `start` and `end` are the plural categories of\n  the corresponding values.\n","publish_time":1583671024331,"_cnpm_publish_time":1583671024331,"dist-tags":{"latest":"2.0.1","next":"2.0.0-1"}}