{"id":16118018,"url":"https://github.com/wessberg/intl-list-format","last_synced_at":"2025-07-03T18:09:29.955Z","repository":{"id":57275464,"uuid":"165755724","full_name":"wessberg/intl-list-format","owner":"wessberg","description":"A fully spec-compliant polyfill for 'Intl.ListFormat'","archived":false,"fork":false,"pushed_at":"2019-07-09T22:21:29.000Z","size":214,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-17T21:06:46.216Z","etag":null,"topics":["ecma-402","ecmascript-internationalization-api","formatting","i18n","internationalization","intl","list","listformat","locale","polyfill"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wessberg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-15T00:14:46.000Z","updated_at":"2022-11-05T15:51:10.000Z","dependencies_parsed_at":"2022-09-15T19:10:35.402Z","dependency_job_id":null,"html_url":"https://github.com/wessberg/intl-list-format","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/wessberg/intl-list-format","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wessberg%2Fintl-list-format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wessberg%2Fintl-list-format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wessberg%2Fintl-list-format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wessberg%2Fintl-list-format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wessberg","download_url":"https://codeload.github.com/wessberg/intl-list-format/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wessberg%2Fintl-list-format/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260484428,"owners_count":23016119,"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":["ecma-402","ecmascript-internationalization-api","formatting","i18n","internationalization","intl","list","listformat","locale","polyfill"],"created_at":"2024-10-09T20:48:23.888Z","updated_at":"2025-07-03T18:09:29.896Z","avatar_url":"https://github.com/wessberg.png","language":"TypeScript","funding_links":["https://www.patreon.com/bePatron?u=11315442"],"categories":[],"sub_categories":[],"readme":"\u003c!-- SHADOW_SECTION_LOGO_START --\u003e\n\n\u003cdiv\u003e\u003cimg alt=\"Logo\" src=\"https://raw.githubusercontent.com/wessberg/intl-list-format/master/documentation/asset/logo.png\" height=\"60\"   /\u003e\u003c/div\u003e\n\n\u003c!-- SHADOW_SECTION_LOGO_END --\u003e\n\n\u003c!-- SHADOW_SECTION_DESCRIPTION_SHORT_START --\u003e\n\n\u003e A fully spec-compliant polyfill for 'Intl.ListFormat'\n\n\u003c!-- SHADOW_SECTION_DESCRIPTION_SHORT_END --\u003e\n\n\u003c!-- SHADOW_SECTION_BADGES_START --\u003e\n\n\u003ca href=\"https://npmcharts.com/compare/intl-list-format?minimal=true\"\u003e\u003cimg alt=\"Downloads per month\" src=\"https://img.shields.io/npm/dm/intl-list-format.svg\"    /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/intl-list-format\"\u003e\u003cimg alt=\"NPM version\" src=\"https://badge.fury.io/js/intl-list-format.svg\"    /\u003e\u003c/a\u003e\n\u003ca href=\"https://david-dm.org/wessberg/intl-list-format\"\u003e\u003cimg alt=\"Dependencies\" src=\"https://img.shields.io/david/wessberg%2Fintl-list-format.svg\"    /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/wessberg/intl-list-format/graphs/contributors\"\u003e\u003cimg alt=\"Contributors\" src=\"https://img.shields.io/github/contributors/wessberg%2Fintl-list-format.svg\"    /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/prettier/prettier\"\u003e\u003cimg alt=\"code style: prettier\" src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\"    /\u003e\u003c/a\u003e\n\u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-yellow.svg\"    /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.patreon.com/bePatron?u=11315442\"\u003e\u003cimg alt=\"Support on Patreon\" src=\"https://img.shields.io/badge/patreon-donate-green.svg\"    /\u003e\u003c/a\u003e\n\n\u003c!-- SHADOW_SECTION_BADGES_END --\u003e\n\n\u003c!-- SHADOW_SECTION_DESCRIPTION_LONG_START --\u003e\n\n## Description\n\n\u003c!-- SHADOW_SECTION_DESCRIPTION_LONG_END --\u003e\n\nThis is a 1:1 implementation of the [`Intl.ListFormat`](https://github.com/tc39/proposal-intl-list-format) draft spec proposal ECMA-402, or the ECMAScript® Internationalization API Specification.\n\nThe `Intl.ListFormat` object is a constructor for objects that enable language-sensitive list formatting.\nIt is a really useful low-level primitive to build on top of which avoids the need to parse lots of CLDR raw data at the expense of your users and their internet connections.\n\nIt builds upon another member of the `Intl` family: `Intl.getCanonicalLocales`, so this must be polyfilled. [See this section for an overview](#dependencies--browser-support).\n\nThis implementation passes all 134 [Test262 Conformance tests](https://github.com/tc39/test262) from the Official ECMAScript Conformance Test Suite.\n\n\u003c!-- SHADOW_SECTION_FEATURES_START --\u003e\n\n### Features\n\n\u003c!-- SHADOW_SECTION_FEATURES_END --\u003e\n\nSome highlights of this polyfill include:\n\n- A very precise implementation of the spec, with cross-references inlined in the source code\n- Conditional loading of Locale data for all CLDR locales\n- Well-tested and well-documented.\n- Passes all Official ECMAScript Conformance Tests\n\n\u003c!-- SHADOW_SECTION_FEATURE_IMAGE_START --\u003e\n\n\u003c!-- SHADOW_SECTION_FEATURE_IMAGE_END --\u003e\n\n\u003c!-- SHADOW_SECTION_TOC_START --\u003e\n\n## Table of Contents\n\n- [Description](#description)\n  - [Features](#features)\n- [Table of Contents](#table-of-contents)\n- [Install](#install)\n  - [NPM](#npm)\n  - [Yarn](#yarn)\n- [Applying the polyfill](#applying-the-polyfill)\n- [Loading locale data](#loading-locale-data)\n- [Usage](#usage)\n  - [Intl.ListFormat.prototype.format](#intllistformatprototypeformat)\n  - [Intl.ListFormat.prototype.formatToParts](#intllistformatprototypeformattoparts)\n  - [Intl.ListFormat.prototype.resolvedOptions](#intllistformatprototyperesolvedoptions)\n  - [Intl.ListFormat.supportedLocalesOf](#intllistformatsupportedlocalesof)\n- [Dependencies \u0026 Browser support](#dependencies--browser-support)\n- [Contributing](#contributing)\n- [Maintainers](#maintainers)\n- [Backers](#backers)\n  - [Patreon](#patreon)\n- [FAQ](#faq)\n  - [What is the default locale?](#what-is-the-default-locale)\n  - [Are there any known quirks?](#are-there-any-known-quirks)\n- [License](#license)\n\n\u003c!-- SHADOW_SECTION_TOC_END --\u003e\n\n\u003c!-- SHADOW_SECTION_INSTALL_START --\u003e\n\n## Install\n\n### NPM\n\n```\n$ npm install intl-list-format\n```\n\n### Yarn\n\n```\n$ yarn add intl-list-format\n```\n\n\u003c!-- SHADOW_SECTION_INSTALL_END --\u003e\n\n## Applying the polyfill\n\nThe polyfill will check for the existence of `Intl.ListFormat` and will _only_ be applied if the runtime doesn't already support it.\n\nTo include it, add this somewhere:\n\n```typescript\nimport \"intl-list-format\";\n\n// Or with commonjs:\nrequire(\"intl-list-format\");\n```\n\nHowever, it is strongly suggested that you only include the polyfill for runtimes that don't already support `Intl.ListFormat`.\nOne way to do so is with an async import:\n\n```typescript\nif (!(\"ListFormat\" in Intl)) {\n\tawait import(\"intl-list-format\");\n\n\t// or with commonjs:\n\trequire(\"intl-list-format\");\n}\n```\n\nAlternatively, you can use [Polyfill.app](https://github.com/wessberg/Polyfiller) which uses this polyfill and takes care of only loading the polyfill if needed as well as adding the language features that the polyfill depends on (See [dependencies](#dependencies--browser-support)).\n\n## Loading locale data\n\nBy default, no CLDR locale data is loaded. Instead, _you_ decide what data you want.\nTo load data, you can import it via the `/locale-data` subfolder that comes with the NPM package:\n\nWith ES modules:\n\n```typescript\n// Load the polyfill\nimport \"intl-list-format\";\n\n// Load data for the 'en' locale\nimport \"intl-list-format/locale-data/en\";\n```\n\nAnd naturally, it also works with commonjs:\n\n```typescript\n// Load the polyfill\nrequire(\"intl-list-format\");\n\n// Load data for the 'en' locale\nrequire(\"intl-list-format/locale-data/en\");\n```\n\nRemember, if you're also depending on a polyfilled version of `Intl.getCanonicalLocales`, you will need to import that polyfill beforehand.\n\n\u003c!-- SHADOW_SECTION_USAGE_START --\u003e\n\n## Usage\n\n\u003c!-- SHADOW_SECTION_USAGE_END --\u003e\n\nThe following examples are taken [directly from the original proposal](https://github.com/tc39/proposal-intl-list-format)\n\n### Intl.ListFormat.prototype.format\n\n```typescript\n// Create a list formatter in your locale\n// with default values explicitly passed in.\nconst lf = new Intl.ListFormat(\"en\", {\n\tlocaleMatcher: \"best fit\", // other values: \"lookup\"\n\ttype: \"conjunction\", // \"conjunction\", \"disjunction\" or \"unit\"\n\tstyle: \"long\" // other values: \"short\" or \"narrow\"\n});\n\nlf.format([\"Motorcycle\", \"Truck\", \"Car\"]);\n// \u003e \"Motorcycle, Truck, and Car\"\n```\n\n### Intl.ListFormat.prototype.formatToParts\n\n```typescript\nconst lf = new Intl.ListFormat(\"en\");\nlf.formatToParts([\"Foo\", \"Bar\", \"Baz\"]);\n// \u003e [\n// \u003e   {type: \"element\", value: \"Foo\"},\n// \u003e   {type: \"literal\", value: \", \"},\n// \u003e   {type: \"element\", value: \"Bar\"},\n// \u003e   {type: \"literal\", value: \", and \"},\n// \u003e   {type: \"element\", value: \"Baz\"}\n// \u003e ]\n```\n\n### Intl.ListFormat.prototype.resolvedOptions\n\n```typescript\nconst lf = new Intl.ListFormat(\"en\", {type: \"unit\", style: \"narrow\"});\n\nlf.resolvedOptions();\n// \u003e {locale: \"en\", style: \"narrow\", type: \"unit\"}\n```\n\n### Intl.ListFormat.supportedLocalesOf\n\n```typescript\nIntl.ListFormat.supportedLocalesOf([\"foo\", \"bar\", \"en-US\"]);\n// \u003e [\"en-US\"]\n```\n\n## Dependencies \u0026 Browser support\n\nThis polyfill is distributed in ES3-compatible syntax, but is using some additional APIs and language features which must be available:\n\n- `Array.prototype.includes`\n- `Object.create`\n- `String.prototype.replace`\n- `Symbol.toStringTag`,\n- `WeakMap`\n- `Intl.getCanonicalLocales`\n\nFor by far the most browsers, these features will already be natively available.\nGenerally, I would highly recommend using something like [Polyfill.app](https://github.com/wessberg/Polyfiller) which takes care of this stuff automatically.\n\n\u003c!-- SHADOW_SECTION_CONTRIBUTING_START --\u003e\n\n## Contributing\n\nDo you want to contribute? Awesome! Please follow [these recommendations](./CONTRIBUTING.md).\n\n\u003c!-- SHADOW_SECTION_CONTRIBUTING_END --\u003e\n\n\u003c!-- SHADOW_SECTION_MAINTAINERS_START --\u003e\n\n## Maintainers\n\n| \u003cimg alt=\"Frederik Wessberg\" src=\"https://avatars2.githubusercontent.com/u/20454213?s=460\u0026v=4\" height=\"70\"   /\u003e                                             |\n| ----------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [Frederik Wessberg](mailto:frederikwessberg@hotmail.com)\u003cbr\u003e\u003cstrong\u003eTwitter\u003c/strong\u003e: [@FredWessberg](https://twitter.com/FredWessberg)\u003cbr\u003e_Lead Developer_ |\n\n\u003c!-- SHADOW_SECTION_MAINTAINERS_END --\u003e\n\n\u003c!-- SHADOW_SECTION_BACKERS_START --\u003e\n\n## Backers\n\n### Patreon\n\n[Become a backer](https://www.patreon.com/bePatron?u=11315442) and get your name, avatar, and Twitter handle listed here.\n\n\u003ca href=\"https://www.patreon.com/bePatron?u=11315442\"\u003e\u003cimg alt=\"Backers on Patreon\" src=\"https://patreon-badge.herokuapp.com/11315442.png\"  width=\"500\"  /\u003e\u003c/a\u003e\n\n\u003c!-- SHADOW_SECTION_BACKERS_END --\u003e\n\n\u003c!-- SHADOW_SECTION_FAQ_START --\u003e\n\n## FAQ\n\n\u003c!-- SHADOW_SECTION_FAQ_END --\u003e\n\n### What is the default locale?\n\nThe default locale will be equal to the locale file you load first.\n\n### Are there any known quirks?\n\nNope!\n\n\u003c!-- SHADOW_SECTION_LICENSE_START --\u003e\n\n## License\n\nMIT © [Frederik Wessberg](mailto:frederikwessberg@hotmail.com) ([@FredWessberg](https://twitter.com/FredWessberg)) ([Website](https://github.com/wessberg))\n\n\u003c!-- SHADOW_SECTION_LICENSE_END --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwessberg%2Fintl-list-format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwessberg%2Fintl-list-format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwessberg%2Fintl-list-format/lists"}