{"name":"@csstools/selector-specificity","description":"Determine selector specificity with postcss-selector-parser","version":"2.0.2","contributors":[{"name":"Antonio Laguna","email":"antonio@laguna.es","url":"https://antonio.laguna.es"},{"name":"Romain Menke","email":"romainmenke@gmail.com"}],"license":"CC0-1.0","funding":{"type":"opencollective","url":"https://opencollective.com/csstools"},"engines":{"node":"^12 || ^14 || >=16"},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","default":"./dist/index.mjs"}},"peerDependencies":{"postcss":"^8.2","postcss-selector-parser":"^6.0.10"},"devDependencies":{"postcss-selector-parser":"^6.0.10"},"scripts":{"build":"rollup -c ../../rollup/default.js","clean":"node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"","lint":"npm run lint:eslint && npm run lint:package-json","lint:eslint":"eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern","lint:package-json":"node ../../.github/bin/format-package-json.mjs","prepublishOnly":"npm run clean && npm run build && npm run test","stryker":"stryker run --logLevel error","test":"npm run test:exports && node ./test/example.mjs && node ./test/test.mjs && node ./test/tests-from-bramus-specificity.mjs && node ./test/tests-from-keeganstreet-specificity.mjs && node ./test/test-compare.mjs","test:exports":"node ./test/_import.mjs && node ./test/_require.cjs"},"homepage":"https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity#readme","repository":{"type":"git","url":"git+https://github.com/csstools/postcss-plugins.git","directory":"packages/selector-specificity"},"bugs":{"url":"https://github.com/csstools/postcss-plugins/issues"},"keywords":["css","postcss-selector-parser","specificity"],"volta":{"extends":"../../package.json"},"gitHead":"9c762dff1caa67c992203452391570e9c6b52f4b","_id":"@csstools/selector-specificity@2.0.2","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-IkpVW/ehM1hWKln4fCA3NzJU8KwD+kIOvPZA4cqxoJHtE21CCzjyp+Kxbu0i5I4tBNOlXPL9mjwnWlL0VEG4Fg==","shasum":"1bfafe4b7ed0f3e4105837e056e0a89b108ebe36","tarball":"http://registry-npm.ywwl.com/@csstools/selector-specificity/download/@csstools/selector-specificity-2.0.2.tgz","fileCount":7,"unpackedSize":14891,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFKHepwDlfxU7ExZ843LP3H/pmUde13O6sr1zLgaKc+bAiAxo2Pc8/fOT9o5hj5emlu6tvUzRj00k3LMb3/91+UhkA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiyEUzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqeJBAAgdKCD1+BotDDju4hPHk+Wf0oayMoLKftRUHwTJ9mrsoXFTNk\r\n99xTUjOFC8XlZZOoSkdMjUSMOC5Q1h59pjUetnI6xp80ToKf2ceeZu7WrDbH\r\nksHyOyUyTT0v2OiiUK7oCwGf6iKpjLesqL5rQEh7uEXRdT+bGlenLhvqQ8xi\r\n8UJsx/wQuv+LaXrh+rlOLqR7xGS2BfVLaYUDVwkiWptcZRQ1MNc3mBqScZje\r\nLFHDeAvcz6GebDrOyx76HNEDBKb2Sa/qAtRUeXmKPj2bDVLmDBXmROmuhyUX\r\n7AOayERX2pN3L2J94OlFenBsfr7HXa+c8UXkawWi3nTmnfD1wA/Wo5cMK7bL\r\nfCK4KL0RO+Sk6uD5njbbpXSFm/Xk4iqfXAFTHQfhJw7Um7c8unNVR2MF0aNc\r\nXj/GmAiF8CZEd0d/0Dualpy2GSHZRg2E0zN5TMn9eimyXyn+ViEtG/zXn7ux\r\n3E4C2hQfGys/4MZz/RVAyoP1LmM4zUVBSWBwsQt/FrWCsWDxDi3H13wuu5fr\r\ntRs6ks2+PRmFB1DPGMpqzT5QEDGRRWy6DUFCE17ohi7AZDGrQIG8BdT62cNA\r\nVTFzJHJh41JvSgmIE0tePj8fqMsFm2VV3ltgIAIcccMsKHPSsThL1VJHR51f\r\n9iWUe4tKoCR4eA+gl05XVVwuWRS4vRzQsII=\r\n=BKqG\r\n-----END PGP SIGNATURE-----\r\n","size":5598,"noattachment":false,"key":"/@csstools/selector-specificity/-/@csstools/selector-specificity-2.0.2.tgz"},"_npmUser":{"name":"alaguna","email":"sombragriselros@gmail.com"},"directories":{},"maintainers":[{"name":"alaguna","email":"sombragriselros@gmail.com"},{"name":"jonathantneal","email":"jonathantneal@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/selector-specificity_2.0.2_1657292083763_0.6225869398661719"},"_hasShrinkwrap":false,"readme":"# Selector Specificity\n\n[<img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@csstools/selector-specificity.svg\" height=\"20\">][npm-url]\n[<img alt=\"Build Status\" src=\"https://github.com/csstools/postcss-plugins/workflows/test/badge.svg\" height=\"20\">][cli-url]\n[<img alt=\"Discord\" src=\"https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white\">][discord]\n\n## Usage\n\nAdd [Selector Specificity] to your project:\n\n```bash\nnpm install @csstools/selector-specificity --save-dev\n```\n\n```js\nimport parser from 'postcss-selector-parser';\nimport { selectorSpecificity } from '@csstools/selector-specificity';\n\nconst selectorAST = parser().astSync('#foo:has(> .foo)');\nconst specificity = selectorSpecificity(selectorAST);\n\nconsole.log(specificity.a); // 1\nconsole.log(specificity.b); // 1\nconsole.log(specificity.c); // 0\n```\n\n_`selectorSpecificity` takes a single selector, not a list of selectors (not : `a, b, c`).\nTo compare or otherwise manipulate lists of selectors you need to call `selectorSpecificity` on each part._\n\n### Comparing\n\nThe package exports a utility function to compare two specificities.\n\n```js\nimport { selectorSpecificity, compare } from '@csstools/selector-specificity';\n\nconst s1 = selectorSpecificity(ast1);\nconst s2 = selectorSpecificity(ast2);\ncompare(s1, s2); // -1 | 0 | 1\n```\n\n- if `s1 < s2` then `compare(s1, s2)` returns a negative number (`< 0`)\n- if `s1 > s2` then `compare(s1, s2)` returns a positive number (`> 0`)\n- if `s1 === s2` then `compare(s1, s2)` returns zero (`=== 0`)\n\n## Prior Art\n\n- [keeganstreet/specificity](https://github.com/keeganstreet/specificity)\n- [bramus/specificity](https://github.com/bramus/specificity)\n\nFor CSSTools we always use `postcss-selector-parser` and want to calculate specificity from this AST.\n\n[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test\n[discord]: https://discord.gg/bUadyRwkJS\n[npm-url]: https://www.npmjs.com/package/@csstools/selector-specificity\n\n[Selector Specificity]: https://github.com/csstools/postcss-plugins/tree/main/packages/selector-specificity\n","publish_time":1657292083935,"_cnpm_publish_time":1657292083935,"dist-tags":{"latest":"6.0.1"}}