{"name":"@formatjs/intl-localematcher","version":"0.8.0","keywords":["ecma402","formatjs","i18n","intl","locale","react-intl","tc39"],"author":{"name":"Long Ho","email":"holevietlong@gmail.com"},"license":"MIT","_id":"@formatjs/intl-localematcher@0.8.0","maintainers":[{"name":"longlho","email":"holevietlong@gmail.com"},{"name":"redonkulus","email":"seth@bertalotto.net"},{"name":"pyrocat","email":"dinglinjie+npm@gmail.com"}],"homepage":"https://github.com/formatjs/formatjs#readme","bugs":{"url":"https://github.com/formatjs/formatjs/issues"},"dist":{"shasum":"84c44db5b650e481837f334ad7b0bf92b559b1ae","tarball":"http://registry-npm.ywwl.com/@formatjs/intl-localematcher/download/@formatjs/intl-localematcher-0.8.0.tgz","fileCount":35,"integrity":"sha512-zgMYWdUlmEZpX2Io+v3LHrfq9xZ6khpQVf9UAw2xYWhGerGgI9XgH1HvL/A34jWiruUJpYlP5pk4g8nIcaDrXQ==","signatures":[{"sig":"MEUCICp5ITNKwemCxpJrCaZMIPdVCHTzOQRU+ooh3WBVWbZXAiEA7fZB3IZJhhDWiVCwC/XeLX7g6gejq4VSqgvO1QiFzfk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@formatjs%2fintl-localematcher@0.8.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":119000,"size":19386,"noattachment":false,"key":"/@formatjs/intl-localematcher/-/@formatjs/intl-localematcher-0.8.0.tgz"},"type":"module","_from":"file:formatjs-intl-localematcher-0.8.0.tgz","types":"index.d.ts","exports":{".":"./index.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:56704f3b-8424-4f89-b62d-8cfc5af9ba2d"}},"_resolved":"/tmp/7071700dbb980f1184346b2500f558bd/formatjs-intl-localematcher-0.8.0.tgz","_integrity":"sha512-zgMYWdUlmEZpX2Io+v3LHrfq9xZ6khpQVf9UAw2xYWhGerGgI9XgH1HvL/A34jWiruUJpYlP5pk4g8nIcaDrXQ==","repository":{"url":"git+https://github.com/formatjs/formatjs.git","type":"git"},"_npmVersion":"11.6.2","description":"Intl.LocaleMatcher ponyfill","directories":{},"sideEffects":false,"_nodeVersion":"24.12.0","dependencies":{"tslib":"^2.8.1","@formatjs/fast-memoize":"3.1.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/intl-localematcher_0.8.0_1768493235833_0.9251373653137194","host":"s3://npm-registry-packages-npm-production"},"readme":"# Intl LocaleMatcher\n\nWe've migrated the docs to https://formatjs.github.io/docs/polyfills/intl-localematcher.\n\n## Performance\n\nThis package implements a highly optimized three-tier locale matching algorithm that provides excellent performance even with large locale sets (700+ locales).\n\n### Benchmark Results\n\nBenchmarked with 725 CLDR locales on Node.js:\n\n| Scenario                                                | Latency | Throughput | Relative Performance |\n| ------------------------------------------------------- | ------- | ---------- | -------------------- |\n| **Tier 1: Exact Match** (`en`)                          | 1.38ms  | 730 ops/s  | Baseline             |\n| **Tier 2: 1-level Fallback** (`en-US` → `en`)           | 1.39ms  | 725 ops/s  | 1.01x slower         |\n| **Tier 2: Maximized Match** (`zh-TW` → `zh-Hant`)       | 1.40ms  | 720 ops/s  | 1.02x slower         |\n| **Tier 3: CLDR Distance** (`sr-Latn-BA` → `sr-Latn-BA`) | 1.38ms  | 730 ops/s  | 1.00x slower         |\n| **Tier 3: Fuzzy Match** (`en-XZ` → `en`)                | 1.50ms  | 670 ops/s  | 1.09x slower         |\n\n### Real-world Impact\n\nThe optimization in this package resolved [issue #4936](https://github.com/formatjs/formatjs/issues/4936), where `DurationFormat` instantiation was taking **610ms** on React Native/Hermes due to slow locale matching against 700+ auto-loaded locales.\n\n**After optimization:**\n\n- Common case (`en-US`): **1.39ms** per instantiation\n- Chinese locales (`zh-TW`): **1.40ms** per instantiation\n- Serbo-Croatian locales: **1.38ms** per instantiation\n\n**Performance improvement: 439x faster** 🚀\n\n### Three-Tier Optimization\n\nThe algorithm uses three tiers for maximum performance:\n\n1. **Tier 1 (Exact Match)**: O(1) Set lookup for exact locale matches\n2. **Tier 2 (Maximization + Fallback)**: Progressive subtag removal with locale maximization\n3. **Tier 3 (CLDR Distance)**: Full UTS #35 Enhanced Language Matching with memoization\n\nThis design ensures that common cases (exact matches and simple fallbacks) are extremely fast, while complex scenarios (script/region matching, language distances) still perform well.\n","publish_time":1768493236008,"_cnpm_publish_time":1768493236008,"dist-tags":{"latest":"0.10.1"}}