{"name":"intl-pluralrules","version":"2.0.0","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"},"type":"commonjs","main":"./polyfill.js","exports":{".":"./polyfill.js","./factory":[{"import":"./factory.mjs","require":"./factory.js"},"./factory.js"],"./plural-rules":"./plural-rules.js","./polyfill":"./polyfill.js","./package.json":"./package.json"},"browser":{"./factory.js":"./factory.mjs"},"react-native":{"./factory":"./factory.js"},"browserslist":["> 0.25%, not dead"],"prettier":{"arrowParens":"avoid","semi":false,"singleQuote":true,"trailingComma":"none"},"devDependencies":{"@babel/core":"^7.11.4","@babel/preset-env":"^7.11.0","@rollup/plugin-babel":"^5.3.0","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^9.0.0","c8":"^7.12.0","chai":"^4.3.6","make-plural":"^7.0.0","mocha":"^10.0.0","mocha-selenium-bridge":"^0.3.0","rollup":"^2.26.5","rollup-plugin-terser":"^7.0.0","test262-harness":"^10.0.0"},"scripts":{"build":"rollup -c","clean":"git clean -fdxe node_modules -e examples/node_modules","prepublishOnly":"npm test && npm run build","test":"c8 mocha test/*.test.mjs","pretest262":"rollup -c test/rollup.test262.js","test262":"test262-harness --error-for-failures --features-exclude cross-realm --prelude test/dist/test262-prelude.js 'test262/test/intl402/PluralRules/**/*.js'","pretest:browsers":"npx rollup -c test/rollup.browser.js","test:browsers":"npm run test:edge && npm run test:firefox && npm run test:safari","test:edge":"BROWSER=Edge:110 mocha-selenium-bridge --driver ./test/browserstack-driver.js http://localhost:8000/test/browser-test.html","test:firefox":"BROWSER=Firefox:110 mocha-selenium-bridge --driver ./test/browserstack-driver.js http://localhost:8000/test/browser-test.html","test:safari":"OS='OS X:Big Sur' BROWSER=Safari:14.1 mocha-selenium-bridge --driver ./test/browserstack-driver.js http://localhost:8000/test/browser-test.html"},"gitHead":"80ea5c7deb3f66c6470d5c33d50e6c91d8426aed","bugs":{"url":"https://github.com/eemeli/intl-pluralrules/issues"},"_id":"intl-pluralrules@2.0.0","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-YlHi/pve75R2kyvGFyDvmL+zECVrEONSbdeGwXtDXHulvNgcmT1rhwyfMCX/BPzBRuW7b2Uu4oQqnYs7ti8WIA==","shasum":"38b8d7df5dd7c8d3bcd7579c2d518ae3bdf29cec","tarball":"http://registry-npm.ywwl.com/intl-pluralrules/download/intl-pluralrules-2.0.0.tgz","fileCount":9,"unpackedSize":59054,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA9a6v6rxfw6GSN0luVYZyS/DsWkmfg347RVT01+oF9PAiAV+aedwsiDUSprm0I4geP/8dY6lhZ4FivEn3llCWsPAA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkLSs5ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrWsA/9HNJyAqEuWiej/Wye88v1WeeW+g4P471zzdf+Tv7NUzhLQoGv\r\nkl1YDvpweTCMSPpZ6u862p67y71ZPInAtNpeUhacK4IHL63HzhrxHhmVt5ZX\r\nQfO4wj1PmcTy0FoqpLhk8aF3/rZmahQieD0ArHSHGvMrCmMR7kfs9WmMz127\r\nAxEYWHpzJDhZvCozWgMd00Cyz2GV6YTPuD6ngcCdvjUTcdQLlNSjwE6LVk5n\r\nBJJ7N6uGkpe+H2vDNP0z+LqqnzY0Kv2imnkmFU0WYZrsekiu8Od4n7HgPXqb\r\n0Jrb9eqgBlGvYL1B8l1aIUEKTPHIl8l2w3KLj0ITxEDRkm47gogpVocFkYEi\r\np3Pj0aKYqifRykrXKj/Nek/nWq/6cv0Z9Nr1sP77awNzruhFPu04acc5ViEw\r\nN0/jKwNjfjCwh5tvJbGU7Nsw0P0kKf8tPQBfkUII96adGj5iUD7VY34zGA85\r\nsQAiz8cJhMhXFeyumlw+42yU57FF3KqyARYj0PK98uJEDETa3yZPE+c9AKnC\r\nXC3PlcFLspwyQ6t2YajXWA0+cHwwzoo3+hAbAyME2ZUdm4Wby3GkQ9qMsz7y\r\nkRCtt0tU7xW5zsLEjMiVMyAv+QJwifV6HTk1lHhICxb+n4MH28U8r/NDZoPE\r\nSFk5HHpNp/jaCtyTPQEDnaBEkTFRDqy5Cx8=\r\n=Qz10\r\n-----END PGP SIGNATURE-----\r\n","size":12553,"noattachment":false,"key":"/intl-pluralrules/-/intl-pluralrules-2.0.0.tgz"},"_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"directories":{},"maintainers":[{"name":"eemeli","email":"eemeli@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/intl-pluralrules_2.0.0_1680681784795_0.3910003536855602"},"_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":1680681785017,"_cnpm_publish_time":1680681785017,"dist-tags":{"latest":"2.0.1","next":"2.0.0-1"}}