{"id":13561776,"url":"https://github.com/fb55/css-what","last_synced_at":"2025-05-14T03:09:16.548Z","repository":{"id":3410269,"uuid":"4460687","full_name":"fb55/css-what","owner":"fb55","description":"a CSS selector parser","archived":false,"fork":false,"pushed_at":"2025-05-09T11:03:21.000Z","size":4807,"stargazers_count":237,"open_issues_count":7,"forks_count":45,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-10T12:08:41.806Z","etag":null,"topics":["css","css-selector-parser","javascript","selector"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fb55.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["fb55"],"tidelift":"npm/css-what"}},"created_at":"2012-05-27T08:24:07.000Z","updated_at":"2025-05-09T11:02:28.000Z","dependencies_parsed_at":"2024-01-16T18:59:42.492Z","dependency_job_id":"4db99ae8-8c4d-449a-941c-f9a5b14bda44","html_url":"https://github.com/fb55/css-what","commit_stats":{"total_commits":1274,"total_committers":24,"mean_commits":"53.083333333333336","dds":0.3751962323390895,"last_synced_commit":"be61077cdd711649bc2cbba5da86217dbf0524c7"},"previous_names":["fb55/csswhat"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fcss-what","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fcss-what/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fcss-what/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fcss-what/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fb55","download_url":"https://codeload.github.com/fb55/css-what/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253639578,"owners_count":21940446,"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":["css","css-selector-parser","javascript","selector"],"created_at":"2024-08-01T13:01:01.007Z","updated_at":"2025-05-14T03:09:16.516Z","avatar_url":"https://github.com/fb55.png","language":"TypeScript","funding_links":["https://github.com/sponsors/fb55","https://tidelift.com/funding/github/npm/css-what","https://tidelift.com/security","https://tidelift.com/subscription/pkg/npm-css-what?utm_source=npm-css-what\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo"],"categories":["TypeScript"],"sub_categories":[],"readme":"# css-what\n\n[![Node.js CI](https://github.com/fb55/css-what/actions/workflows/nodejs-test.yml/badge.svg)](https://github.com/fb55/css-what/actions/workflows/nodejs-test.yml)\n[![Coverage](https://img.shields.io/coveralls/github/fb55/css-what/master)](https://coveralls.io/github/fb55/css-what?branch=master)\n\nA CSS selector parser.\n\n## Example\n\n```js\nimport * as CSSwhat from \"css-what\";\n\nCSSwhat.parse(\"foo[bar]:baz\")\n\n~\u003e [\n    [\n        { type: \"tag\", name: \"foo\" },\n        {\n            type: \"attribute\",\n            name: \"bar\",\n            action: \"exists\",\n            value: \"\",\n            ignoreCase: null\n        },\n        { type: \"pseudo\", name: \"baz\", data: null }\n    ]\n]\n```\n\n## API\n\n**`CSSwhat.parse(selector)` - Parses `selector`.**\n\nThe function returns a two-dimensional array. The first array represents selectors separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are:\n\n| name                | properties                              | example       | output                                                                                   |\n| ------------------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------- |\n| `tag`               | `name`                                  | `div`         | `{ type: 'tag', name: 'div' }`                                                           |\n| `universal`         | -                                       | `*`           | `{ type: 'universal' }`                                                                  |\n| `pseudo`            | `name`, `data`                          | `:name(data)` | `{ type: 'pseudo', name: 'name', data: 'data' }`                                         |\n| `pseudo`            | `name`, `data`                          | `:name`       | `{ type: 'pseudo', name: 'name', data: null }`                                           |\n| `pseudo-element`    | `name`                                  | `::name`      | `{ type: 'pseudo-element', name: 'name' }`                                               |\n| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr]`      | `{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }`    |\n| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr=val]`  | `{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }` |\n| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr^=val]` | `{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }`  |\n| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr$=val]` | `{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }`    |\n| `child`             | -                                       | `\u003e`           | `{ type: 'child' }`                                                                      |\n| `parent`            | -                                       | `\u003c`           | `{ type: 'parent' }`                                                                     |\n| `sibling`           | -                                       | `~`           | `{ type: 'sibling' }`                                                                    |\n| `adjacent`          | -                                       | `+`           | `{ type: 'adjacent' }`                                                                   |\n| `descendant`        | -                                       |               | `{ type: 'descendant' }`                                                                 |\n| `column-combinator` | -                                       | `\\|\\|`        | `{ type: 'column-combinator' }`                                                          |\n\n**`CSSwhat.stringify(selector)` - Turns `selector` back into a string.**\n\n---\n\nLicense: BSD-2-Clause\n\n## Security contact information\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).\nTidelift will coordinate the fix and disclosure.\n\n## `css-what` for enterprise\n\nAvailable as part of the Tidelift Subscription\n\nThe maintainers of `css-what` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-css-what?utm_source=npm-css-what\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fcss-what","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffb55%2Fcss-what","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fcss-what/lists"}