Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # matcher [![Build Status](https://travis-ci.com/sindresorhus/matcher.svg?branch=master)](https://travis-ci.com/sindresorhus/matcher)
  2. > Simple [wildcard](https://en.wikipedia.org/wiki/Wildcard_character) matching
  3. Useful when you want to accept loose string input and regexes/globs are too convoluted.
  4. ## Install
  5. ```
  6. $ npm install matcher
  7. ```
  8. ## Usage
  9. ```js
  10. const matcher = require('matcher');
  11. matcher(['foo', 'bar', 'moo'], ['*oo', '!foo']);
  12. //=> ['moo']
  13. matcher(['foo', 'bar', 'moo'], ['!*oo']);
  14. //=> ['bar']
  15. matcher.isMatch('unicorn', 'uni*');
  16. //=> true
  17. matcher.isMatch('unicorn', '*corn');
  18. //=> true
  19. matcher.isMatch('unicorn', 'un*rn');
  20. //=> true
  21. matcher.isMatch('rainbow', '!unicorn');
  22. //=> true
  23. matcher.isMatch('foo bar baz', 'foo b* b*');
  24. //=> true
  25. matcher.isMatch('unicorn', 'uni\\*');
  26. //=> false
  27. matcher.isMatch('UNICORN', 'UNI*', {caseSensitive: true});
  28. //=> true
  29. matcher.isMatch('UNICORN', 'unicorn', {caseSensitive: true});
  30. //=> false
  31. matcher.isMatch(['foo', 'bar'], 'f*');
  32. //=> true
  33. matcher.isMatch(['foo', 'bar'], ['a*', 'b*']);
  34. //=> true
  35. matcher.isMatch('unicorn', ['tri*', 'UNI*'], {caseSensitive: true});
  36. //=> false
  37. ```
  38. ## API
  39. It matches even across newlines. For example, `foo*r` will match `foo\nbar`.
  40. ### matcher(inputs, patterns, options?)
  41. Accepts an array of `input`'s and `pattern`'s.
  42. Returns an array of `inputs` filtered based on the `patterns`.
  43. ### matcher.isMatch(input, pattern, options?)
  44. Accepts either a string or array of strings for both `input` and `pattern`.
  45. Returns a `boolean` of whether any given `input` matches every given `pattern`.
  46. #### input
  47. Type: `string | string[]`
  48. String or array of strings to match.
  49. #### options
  50. Type: `object`
  51. ##### caseSensitive
  52. Type: `boolean`\
  53. Default: `false`
  54. Treat uppercase and lowercase characters as being the same.
  55. Ensure you use this correctly. For example, files and directories should be matched case-insensitively, while most often, object keys should be matched case-sensitively.
  56. #### pattern
  57. Type: `string | string[]`
  58. Use `*` to match zero or more characters. A pattern starting with `!` will be negated.
  59. ## Benchmark
  60. ```
  61. $ npm run bench
  62. ```
  63. ## Related
  64. - [matcher-cli](https://github.com/sindresorhus/matcher-cli) - CLI for this module
  65. - [multimatch](https://github.com/sindresorhus/multimatch) - Extends `minimatch.match()` with support for multiple patterns
  66. ---
  67. <div align="center">
  68. <b>
  69. <a href="https://tidelift.com/subscription/pkg/npm-matcher?utm_source=npm-matcher&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
  70. </b>
  71. <br>
  72. <sub>
  73. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  74. </sub>
  75. </div>