{"id":22689547,"url":"https://github.com/efoken/css-mediaquery2","last_synced_at":"2026-02-21T11:31:21.956Z","repository":{"id":160299871,"uuid":"614281771","full_name":"efoken/css-mediaquery2","owner":"efoken","description":"Parses and determines if a given CSS Media Query matches a set of values via JavaScript.","archived":false,"fork":false,"pushed_at":"2024-12-20T08:00:10.000Z","size":298,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T09:47:04.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/efoken.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-03-15T09:18:24.000Z","updated_at":"2024-12-20T08:00:14.000Z","dependencies_parsed_at":"2025-04-12T06:05:19.646Z","dependency_job_id":"2b22ce9d-2aaa-48bf-892d-447ce901d5f2","html_url":"https://github.com/efoken/css-mediaquery2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/efoken/css-mediaquery2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efoken%2Fcss-mediaquery2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efoken%2Fcss-mediaquery2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efoken%2Fcss-mediaquery2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efoken%2Fcss-mediaquery2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efoken","download_url":"https://codeload.github.com/efoken/css-mediaquery2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efoken%2Fcss-mediaquery2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29679794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T11:29:27.227Z","status":"ssl_error","status_checked_at":"2026-02-21T11:29:20.292Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-12-10T00:19:53.430Z","updated_at":"2026-02-21T11:31:21.950Z","avatar_url":"https://github.com/efoken.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSS Media Query 2\n\n[![npm latest package](https://img.shields.io/npm/v/css-mediaquery2/latest.svg)](https://www.npmjs.com/package/css-mediaquery2)\n[![bundle size](https://img.shields.io/bundlephobia/minzip/css-mediaquery2.svg)](https://bundlephobia.com/package/css-mediaquery2)\n\nParses and determines if a given CSS Media Query matches a set of values via\nJavaScript.\n\n## Installation\n\nInstall via npm:\n\n```bash\nnpm install css-mediaquery2\n```\n\n## Usage\n\nThis package has two exports: `parse()`, and `match()` which can parse CSS Media\nQueries and determine if a media query matches a given set of values.\n\n### Matching\n\nThe `match()` method lets you compare a media query expression with a JavaScript\nobject and determine if a media query matches a given set of values.\n\n```js\nimport MediaQuery from \"css-mediaquery2\"\n\nconst matches = MediaQuery.match(\"screen and (min-width: 40em)\", {\n  type: \"screen\",\n  width: \"1024px\",\n})\nconsole.log(matches) // =\u003e true\n```\n\nThe values specified to check a media query string against should be thought of\nas if they are the current state of a device/browser. A `type` value _must_ be\nspecified, and it can _not_ be `\"all\"`.\n\n### Parsing\n\nExisting CSS Parsers don't do a great job at parsing the details of media\nqueries. That's where `css-mediaquery2` shines. You can parse a media query\nexpression and get an AST back by using the `parse()` method.\n\n```js\nimport MediaQuery from \"css-mediaquery2\"\n\nconst ast = MediaQuery.parse(\"screen and (min-width: 48em)\")\n```\n\nThe `ast` variable will have the following payload:\n\n```js\n;[\n  {\n    inverse: false,\n    type: \"screen\",\n    expressions: [\n      {\n        modifier: \"min\",\n        feature: \"width\",\n        value: \"48em\",\n      },\n    ],\n  },\n]\n```\n\nThis package was written with care to following the W3C Recommendations for\n[CSS3 Media Queries](http://www.w3.org/TR/css3-mediaqueries/) and\n[CSS3 Values and Units](http://www.w3.org/TR/css3-values/). It supports all of\nthe [Media Features](http://www.w3.org/TR/css3-mediaqueries/#media1) and will\nproperly convert values to a common unit before comparing them.\n\n## License\n\nThis software is free to use under the ISC license. See the\n[LICENSE file](https://github.com/efoken/css-mediaquery2/blob/main/LICENSE) for\nlicense text and copyright information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefoken%2Fcss-mediaquery2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefoken%2Fcss-mediaquery2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefoken%2Fcss-mediaquery2/lists"}