{"name":"specificity","version":"0.4.0","description":"Calculate the specificity of a CSS selector","keywords":["CSS","specificity"],"homepage":"https://github.com/keeganstreet/specificity","author":{"name":"Keegan Street","url":"http://keegan.st"},"repository":{"type":"git","url":"git+https://github.com/keeganstreet/specificity.git"},"license":"MIT","bugs":{"url":"https://github.com/keeganstreet/specificity/issues"},"main":"dist/specificity","module":"dist/specificity.mjs","bin":{"specificity":"./bin/specificity"},"scripts":{"prepare":"rollup --config","test":"mocha test/test.js --require esm"},"devDependencies":{"esm":"^3.0.71","mocha":"^5.2.0","rollup":"^0.62.0"},"types":"specificity.d.ts","gitHead":"b39fbff6f21e862eefaf63fde7b2abcd2e4ab5da","_id":"specificity@0.4.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.1","_npmUser":{"name":"keeganstreet","email":"keeganstreet@gmail.com"},"dist":{"integrity":"sha512-nGUlURFuoSsmJQ2TBKaO2l7+dBHtRnofSSQdiFKEpd+HBDWXR9/+gtJfgNpe3Nh6o5mqSxDpin/M4YoN7AijGg==","shasum":"301b1ab5455987c37d6d94f8c956ef9d9fb48c1d","tarball":"http://registry-npm.ywwl.com/specificity/download/specificity-0.4.0.tgz","fileCount":10,"unpackedSize":35634,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbTdSJCRA9TVsSAnZWagAAIqYP/j5FkxA6+TDEGwwcT24D\nupw3gU+K4JkcfcQM4aeuK3Zt8YwMldw9oQtKi7GDcHFZ4IT4b1a0MTxJRFUP\n95vCeC78BHCG+xwwpFgbCF8Xgkf27vJs9q1ZGYZ9h1sxa+4IR3ayQ2CcQ8Zc\nNIfho70/LXF8RskmpuWDXqQ3RH36K6hzIVitiiOILg9GehyHQ+V3DdjTCEbf\nv5Qm1zRMo4HSxdhmXk0rh1Px5K+aIeOrSwPOiPJDyTXTQcDc22l91WrF+GSR\n/ZxIGLpfJ3foDzCn/O+pSjC1FODeLNVg6oQup/xyUFsoZKqwM/FRes0qXeoZ\n/tByLXHHKPtAWMD8prTFxUYiyPfy/6P62HPFfmy8dsGBAoIee2btVPiMeEwS\nxFmNW3wGymNLHQzjKKDK+BU9Er7yPn/HrIz8QW9vqMjKUy6dObs1+el5/phX\npIKpUp/OyKAZzihbDPNwnn6g7nw/YuD9TqzAw/HqzutjZ5pfsHra/QKISGXp\nPSqqHOL5B9h/paUv4KlSO3A579oI/Vjvbd5PynkEjKEy61EQ7TpBxsWn78Hf\npnr41F8CRbcInN+yOJxI+pJOrxFMvIJGue5pjYz8GT4C2Q3CpHO2BFU54P4y\n1ZlK2kuQjgatqmLp8Y9XFhGvOZZNMCuChPKmo4DwqZe+RJLCRhDLm12IwqHf\nTAP6\r\n=bw5y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEgz+jqi64XLDo/YdM3sVdrI5e/7rdTX+H+Re3FVyPM9AiA8L/URkyThmI/ktGADTfRJ8FcuwgqkS1vGADeWhgEeLA=="}],"size":7885,"noattachment":false,"key":"/specificity/-/specificity-0.4.0.tgz"},"maintainers":[{"name":"keeganstreet","email":"keeganstreet@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/specificity_0.4.0_1531827337441_0.7529351083993481"},"_hasShrinkwrap":false,"readme":"# Specificity Calculator\n\nA JavaScript module for calculating and comparing the [specificity of CSS selectors](https://www.w3.org/TR/selectors-4/#specificity). The module is used on the [Specificity Calculator](https://specificity.keegan.st/) website.\n\nNote that version 1 is a complete re-write with support for CSS Selectors Level 4, and has a different API than earlier versions.\n\n## calculate(selector)\n\n### Parameters\n\n- `selector`: `string` - should be a valid CSS selector\n\n### Returns\n\nA `Specificity` object with a type of `Record<\"A\" | \"B\" | \"C\", number>`.\n\n### Examples\n\n```js\ncalculate(\"#id\");\n{\n  A: 1,\n  B: 0,\n  C: 0\n}\n\ncalculate(\".classname\");\n{\n  A: 0,\n  B: 1,\n  C: 0\n}\n\ncalculate(\"element\");\n{\n  A: 0,\n  B: 0,\n  C: 1\n}\n\ncalculate('ul#nav li.active a');\n{\n  A: 1,\n  B: 1,\n  C: 3\n}\n```\n\n## compare(a, b)\n\n### Parameters\n\n- `a`: `Specificity` object with a type of `Record<\"A\" | \"B\" | \"C\", number>`\n- `b`: `Specificity` object with a type of `Record<\"A\" | \"B\" | \"C\", number>`\n\n### Returns\n\nReturns a positive number if `a` has a higher specificity than `b`\nReturns a negative number if `a` has a lower specificity than `b`\nReturns `0` if `a` has the same specificity than `b`\n\n### Examples\n\n```js\n[\n  \"element\",\n  \".classname\",\n  \"#id\",\n]\n  .map(calculate)\n  .sort(compare);\n\n[ { A: 0, B: 0, C: 1 }, { A: 0, B: 1, C: 0 }, { A: 1, B: 0, C: 0 } ]\n```\n\n## compareDesc(a, b)\n\nSame as `compare` but returns the opposite value, for use in sorting specificity objects with the highest specificity first.\n","publish_time":1531827337501,"_cnpm_publish_time":1531827337501,"dist-tags":{"latest":"1.0.0","next":"1.0.0-beta"}}