{"_id":"style-search","_rev":"106706","name":"style-search","description":"Search CSS(-like) strings","dist-tags":{"latest":"0.1.0"},"maintainers":[{"name":"davidtheclark","email":"david.dave.clark@gmail.com"}],"time":{"modified":"2021-06-03T10:38:43.000Z","created":"2016-06-12T14:23:02.634Z","0.1.0":"2016-06-12T14:23:02.634Z"},"users":{},"author":{"name":"David Clark"},"repository":{"type":"git","url":"git+https://github.com/davidtheclark/style-search.git"},"versions":{"0.1.0":{"name":"style-search","version":"0.1.0","description":"Search CSS(-like) strings","main":"index.js","scripts":{"test":"tape test.js"},"repository":{"type":"git","url":"git+https://github.com/davidtheclark/style-search.git"},"keywords":["css","search","stylelint"],"author":{"name":"David Clark"},"license":"ISC","bugs":{"url":"https://github.com/davidtheclark/style-search/issues"},"homepage":"https://github.com/davidtheclark/style-search#readme","devDependencies":{"tape":"^4.5.1"},"gitHead":"e7e02010544c9204bbbc323cf3b18ae1a0fcb39b","_id":"style-search@0.1.0","_shasum":"7958c793e47e32e07d2b5cafe5c0bf8e12e77902","_from":".","_npmVersion":"2.15.6","_nodeVersion":"4.4.5","_npmUser":{"name":"davidtheclark","email":"david.dave.clark@gmail.com"},"dist":{"shasum":"7958c793e47e32e07d2b5cafe5c0bf8e12e77902","size":5617,"noattachment":false,"key":"/style-search/-/style-search-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/style-search/download/style-search-0.1.0.tgz"},"maintainers":[{"name":"davidtheclark","email":"david.dave.clark@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/style-search-0.1.0.tgz_1465741382107_0.05674637807533145"},"directories":{},"publish_time":1465741382634,"_cnpm_publish_time":1465741382634,"_hasShrinkwrap":false}},"readme":"# style-search [![CircleCI](https://circleci.com/gh/davidtheclark/style-search.svg?style=svg)](https://circleci.com/gh/davidtheclark/style-search)\n\nSearch CSS (and CSS-like) strings, with sensitivity to whether matches occur inside strings, comments, and functions.\n\n## Usage\n\n```js\nvar styleSearch = require('style-search');\n\nstyleSearch(options, callback);\n```\n\n**By default, the search ignores strings, comments, and function names.** You can use the options to change this behavior or introduce other restrictions. That is what makes this module more useful for many searches than `indexOf()` or a `RegExp`.\n\nHowever, if you need more detailed parsing, you should consider using the real parsers [PostCSS](https://github.com/postcss/postcss), [`postcss-selector-parser`](https://github.com/postcss/postcss-selector-parser), and [`postcss-value-parser`](https://github.com/TrySound/postcss-value-parser).\n\n### Example\n\n```css\n/* Here is some pink */\na { color: pink; }\na::before { content: \"pink\" }\nb { color: shadesOfPink(7); }\n```\n\n```js\nstyleSearch({\n  source: theCssStringAbove,\n  target: \"pink\",\n}, function(match, count) {\n  /* Only the \"pink\" in `color: pink` will be\n  reported as a match */\n});\n```\n\n### Reporting matches\n\nFor every match found your `callback` is invoked. It is passed two arguments:\n\n- A `match` object with the following properties:\n  - `startIndex`: where the match begins\n  - `endIndex`: where the match ends\n  - `target`: what got matched (useful if your `target` option is an array instead of a single string)\n  - `insideFunctionArguments`: whether the match is inside a function — *this includes the parentheses around the arguments*\n  - `insideComment`: whether the match is inside a comment\n  - `insideString`: whether the match is inside a string\n- The count of how many matches have been found up to this point.\n\n### Options\n\nBelow you'll see that syntax feature options all accept three keywords: `\"skip\"`, `\"check\"`, `\"only\"`. An error will be thrown if you use `\"only\"` more than once.\n\n#### source\n\nString. *Required.*\n\nThe source string to search through.\n\n#### target\n\nString or array of strings. *Required.*\n\nThe target of the search. Can be\n- a single character\n- a string with some length\n- an array of strings, all of which count as matches (the `match` object passed to the `callback` will differentiate which string in the array got matched via its `target` property)\n\n#### once\n\nBoolean. Default: `false`.\n\nIf `true`, the search will stop after one match is found.\n\n#### comments\n\n`\"skip\"` | `\"check\"` | `\"only\"`. Default: `\"skip\"`.\n\nThis includes both standard `/* CSS comments */` and non-standard but widely used `// single line comments`.\n\n#### strings\n\n`\"skip\"` | `\"check\"` | `\"only\"`. Default: `\"skip\"`.\n\n#### functionNames\n\n`\"skip\"` | `\"check\"` | `\"only\"`. Default: `\"skip\"`.\n\n#### functionArguments\n\n`\"skip\"` | `\"check\"` | `\"only\"`. Default: `\"check\"`.\n\n#### parentheticals\n\n`\"skip\"` | `\"check\"` | `\"only\"`. Default: `\"check\"`.\n\nThis designates anything inside parentheses, which includes standard functions, but also Sass maps and other non-standard constructs. `parentheticals` is a broader category than `functionArguments`.\n","_attachments":{},"homepage":"https://github.com/davidtheclark/style-search#readme","bugs":{"url":"https://github.com/davidtheclark/style-search/issues"},"license":"ISC"}