{"_id":"matcher@7.0.0","bugs":{"url":"https://github.com/sindresorhus/matcher/issues"},"dist":{"shasum":"3cdf78863a530bab95e11d44903e830f6a55196c","tarball":"http://registry-npm.ywwl.com/matcher/download/matcher-7.0.0.tgz","fileCount":5,"integrity":"sha512-ygfIhMQiuhHCxssmtMDdKypUAXIiKn1JtVwdUD5Nb30t7wFFIyctviPvOraA/2d3vFApzLKFm2c64x/KwuxsgA==","signatures":[{"sig":"MEUCIQC44LtbCocaOjWX5H4wxOMKKje3ZetdFTth1899mu+oZQIgSfRKiUTI+o3YCo61dxyz7bi6a4arcsjoF1Jm2Zw0k8c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCP1ymPi9nl4VFDRKLcJ09zG7jmVt8/RslqufTxdtSpYgIhAMqZytkyCEzQ/JnUfcw53/nw+dCOlT/RFZpeemqevoDs"}],"unpackedSize":17415,"size":5413,"noattachment":false,"key":"/matcher/-/matcher-7.0.0.tgz"},"name":"matcher","type":"module","types":"./index.d.ts","author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"engines":{"node":">=22"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"1cc522ff404ba896cb57332d66a67634ded098a4","license":"MIT","scripts":{"test":"xo && node --test","bench":"_matcha bench.js"},"version":"7.0.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"homepage":"https://github.com/sindresorhus/matcher#readme","keywords":["matching","match","regex","regexp","regular","expression","wildcard","pattern","string","filter","glob","globber","globbing","minimatch"],"repository":{"url":"git+https://github.com/sindresorhus/matcher.git","type":"git"},"_npmVersion":"12.0.1","description":"Simple wildcard matching","directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"sideEffects":false,"_nodeVersion":"26.9.0","_hasShrinkwrap":false,"devDependencies":{"xo":"^5.0.1","matcha":"^0.7.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/matcher_7.0.0_1790457801705_0.4936698859009716"},"readme":"# matcher\n\n> Simple [wildcard](https://en.wikipedia.org/wiki/Wildcard_character) matching\n\nUseful when you want to accept loose string input and regexes/globs are too convoluted.\n\n## Install\n\n```sh\nnpm install matcher\n```\n\n## Usage\n\n```js\nimport {matcher, isMatch} from 'matcher';\n\nmatcher(['foo', 'bar', 'moo'], ['*oo', '!foo']);\n//=> ['moo']\n\nmatcher(['foo', 'bar', 'moo'], ['!*oo']);\n//=> ['bar']\n\nmatcher('moo', ['']);\n//=> []\n\nmatcher('moo', []);\n//=> []\n\nmatcher([''], ['']);\n//=> ['']\n\nisMatch('unicorn', 'uni*');\n//=> true\n\nisMatch('unicorn', '*corn');\n//=> true\n\nisMatch('unicorn', 'un*rn');\n//=> true\n\nisMatch('rainbow', '!unicorn');\n//=> true\n\nisMatch('foo bar baz', 'foo b* b*');\n//=> true\n\nisMatch('unicorn', 'uni\\\\*');\n//=> false\n\nisMatch(['foo', 'bar'], 'f*');\n//=> true\n\nisMatch(['foo', 'bar'], ['a*', 'b*']);\n//=> true\n\nisMatch('unicorn', ['']);\n//=> false\n\nisMatch('unicorn', []);\n//=> false\n\nisMatch([], 'bar');\n//=> false\n\nisMatch([], []);\n//=> false\n\nisMatch([''], ['']);\n//=> true\n\n// With `allPatterns` option\nisMatch('foobar', ['foo*', '*bar'], {allPatterns: true});\n//=> true\n\nisMatch('foo', ['foo*', '*bar'], {allPatterns: true});\n//=> false\n```\n\n## API\n\nIt matches even across newlines. For example, `foo*r` will match `foo\\nbar`.\n\n### matcher(inputs, patterns, options?)\n\nAccepts a string or an array of strings for both `inputs` and `patterns`.\n\nReturns an array of `inputs` filtered based on the `patterns`.\n\n### isMatch(inputs, patterns, options?)\n\nAccepts a string or an array of strings for both `inputs` and `patterns`.\n\nReturns a `boolean` of whether any of the given `inputs` matches the `patterns`. With `allPatterns` enabled, an input has to match every non-negated pattern, not just one.\n\n#### inputs\n\nType: `string | string[]`\n\nThe string or array of strings to match.\n\n#### options\n\nType: `object`\n\n##### caseSensitive\n\nType: `boolean`\\\nDefault: `false`\n\nMake matching case-sensitive. When `false`, treats uppercase and lowercase characters as being the same, the way a case-insensitive regular expression without the `u` flag does. So a character whose uppercase form is more than one character (`ß`) or is ASCII while the character itself is not (`ı`, `ſ`), and every character outside the Basic Multilingual Plane, only matches itself.\n\nEnsure you use this correctly. For example, files and directories should be matched case-insensitively, while most often, object keys should be matched case-sensitively.\n\n```js\nimport {isMatch} from 'matcher';\n\nisMatch('UNICORN', 'UNI*', {caseSensitive: true});\n//=> true\n\nisMatch('UNICORN', 'unicorn', {caseSensitive: true});\n//=> false\n\nisMatch('unicorn', ['tri*', 'UNI*'], {caseSensitive: true});\n//=> false\n```\n\n##### allPatterns\n\nType: `boolean`\\\nDefault: `false`\n\nA negated pattern always excludes the inputs it matches, whether or not this option is set. Setting it also requires every non-negated pattern to match the same input, instead of at least one of them.\n\n```js\nimport {matcher} from 'matcher';\n\n// Find text strings containing both \"edge\" and \"tiger\" in arbitrary order, but not \"stunt\".\nconst demo = (strings) => matcher(strings, ['*edge*', '*tiger*', '!*stunt*'], {allPatterns: true});\n\ndemo(['Hey, tiger!', 'tiger has edge over hyenas', 'pushing a tiger over the edge is a stunt']);\n//=> ['tiger has edge over hyenas']\n```\n\n```js\nimport {matcher} from 'matcher';\n\nmatcher(['foo', 'for', 'bar'], ['f*', 'b*', '!x*'], {allPatterns: true});\n//=> []\n\nmatcher(['foo', 'for', 'bar'], ['f*'], {allPatterns: true});\n//=> ['foo', 'for']\n```\n\n#### patterns\n\nType: `string | string[]`\n\nUse `*` to match zero or more characters.\n\nA leading `!` negates the pattern.\n\nA `\\` escapes the character after it, so `\\*` matches a literal `*` and `\\\\` matches a literal `\\`. A `\\` at the very end of a pattern matches itself.\n\nAn input string will be omitted if there is no pattern at all, if it matches a negated pattern, or if there are non-negated patterns and it fails to match them: all of them when `allPatterns` is set, at least one otherwise. When every pattern is negated, an input is kept as long as it matches none of them.\n\n```js\nimport {isMatch} from 'matcher';\n\nisMatch('unicorn', 'uni\\\\*');\n//=> false\n\nisMatch('uni*', 'uni\\\\*');\n//=> true\n\n// Every backslash in a Windows path has to be doubled, otherwise the first one escapes the second.\nisMatch('C:\\\\temp\\\\x', 'C:\\\\\\\\temp\\\\\\\\*');\n//=> true\n\nisMatch('C:\\\\temp\\\\x', 'C:\\\\temp\\\\*');\n//=> false\n```\n\n## Benchmark\n\n```sh\nnpm run bench\n```\n\n## Related\n\n- [matcher-cli](https://github.com/sindresorhus/matcher-cli) - CLI for this module\n- [multimatch](https://github.com/sindresorhus/multimatch) - Extends `minimatch.match()` with support for multiple patterns\n","publish_time":1790457801808,"_cnpm_publish_time":1790457801808,"dist-tags":{"latest":"7.0.0"}}