{"id":15413448,"url":"https://github.com/wooorm/comma-separated-tokens","last_synced_at":"2025-10-24T08:51:40.039Z","repository":{"id":57203976,"uuid":"52310075","full_name":"wooorm/comma-separated-tokens","owner":"wooorm","description":"Parse and stringify comma-separated tokens","archived":false,"fork":false,"pushed_at":"2022-11-14T09:08:57.000Z","size":73,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-05T02:25:50.943Z","etag":null,"topics":["comma","comma-separated","html","separated","tokens"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/wooorm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":"funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"wooorm"}},"created_at":"2016-02-22T22:16:03.000Z","updated_at":"2024-07-01T19:29:02.000Z","dependencies_parsed_at":"2022-09-06T11:12:07.964Z","dependency_job_id":null,"html_url":"https://github.com/wooorm/comma-separated-tokens","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/wooorm/comma-separated-tokens","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcomma-separated-tokens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcomma-separated-tokens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcomma-separated-tokens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcomma-separated-tokens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wooorm","download_url":"https://codeload.github.com/wooorm/comma-separated-tokens/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcomma-separated-tokens/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280768886,"owners_count":26387533,"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","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["comma","comma-separated","html","separated","tokens"],"created_at":"2024-10-01T16:57:08.331Z","updated_at":"2025-10-24T08:51:40.010Z","avatar_url":"https://github.com/wooorm.png","language":"JavaScript","funding_links":["https://github.com/sponsors/wooorm"],"categories":[],"sub_categories":[],"readme":"# comma-separated-tokens\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n\nParse and stringify comma-separated tokens.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`parse(value)`](#parsevalue)\n    *   [`stringify(values[, options])`](#stringifyvalues-options)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [Security](#security)\n*   [License](#license)\n\n## What is this?\n\nThis is a tiny package that can parse and stringify comma-separated tokens, as\nused for example in the HTML `accept` attribute, according to the\n[WHATWG spec][spec].\n\n## When should I use this?\n\nThis package is rather niche, it’s low-level and particularly useful when\nworking with [hast][].\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 14.14+, 16.0+), install with [npm][]:\n\n```sh\nnpm install comma-separated-tokens\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {parse, stringify} from 'https://esm.sh/comma-separated-tokens@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {parse, stringify} from 'https://esm.sh/comma-separated-tokens@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {parse, stringify} from 'comma-separated-tokens'\n\nparse(' a ,b,,d d ') //=\u003e ['a', 'b', '', 'd d']\nstringify(['a', 'b', '', 'd d']) //=\u003e 'a, b, , d d'\n```\n\n## API\n\nThis package exports the identifier `parse` and `stringify`.\nThere is no default export.\n\n### `parse(value)`\n\nParse commma-separated tokens (`string`) to an array of strings\n(`Array\u003cstring\u003e`), according to the [WHATWG spec][spec].\n\n### `stringify(values[, options])`\n\nSerialize an array of strings or numbers (`Array\u003cstring|number\u003e`) to\ncomma-separated tokens (`string`).\nHandles empty items at start or end correctly.\n\n\u003e 👉 **Note**: it’s not possible to specify initial or final whitespace per\n\u003e value.\n\n##### `options`\n\nConfiguration (optional).\n\n###### `options.padLeft`\n\nWhether to pad a space before a token (`boolean`, default: `true`).\n\n###### `options.padRight`\n\nWhether to pad a space after a token (`boolean`, default: `false`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type `Options`.\n\n## Compatibility\n\nThis package is at least compatible with all maintained versions of Node.js.\nAs of now, that is Node.js 14.14+ and 16.0+.\nIt also works in Deno and modern browsers.\n\n## Related\n\n*   [`space-separated-tokens`](https://github.com/wooorm/space-separated-tokens)\n    — parse/stringify space-separated tokens\n*   [`collapse-white-space`](https://github.com/wooorm/collapse-white-space)\n    — replace multiple white-space characters with a single space\n*   [`property-information`](https://github.com/wooorm/property-information)\n    — info on HTML properties\n\n## Contribute\n\nYes please!\nSee [How to Contribute to Open Source][contribute].\n\n## Security\n\nThis package is safe.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/wooorm/comma-separated-tokens/workflows/main/badge.svg\n\n[build]: https://github.com/wooorm/comma-separated-tokens/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/comma-separated-tokens.svg\n\n[coverage]: https://codecov.io/github/wooorm/comma-separated-tokens\n\n[downloads-badge]: https://img.shields.io/npm/dm/comma-separated-tokens.svg\n\n[downloads]: https://www.npmjs.com/package/comma-separated-tokens\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/comma-separated-tokens.svg\n\n[size]: https://bundlephobia.com/result?p=comma-separated-tokens\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[contribute]: https://opensource.guide/how-to-contribute/\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[spec]: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#comma-separated-tokens\n\n[hast]: https://github.com/syntax-tree/hast\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fcomma-separated-tokens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwooorm%2Fcomma-separated-tokens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fcomma-separated-tokens/lists"}