Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.d.ts 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. declare namespace matcher {
  2. interface Options {
  3. /**
  4. Treat uppercase and lowercase characters as being the same.
  5. 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.
  6. @default false
  7. */
  8. readonly caseSensitive?: boolean;
  9. }
  10. }
  11. declare const matcher: {
  12. /**
  13. Simple [wildcard](https://en.wikipedia.org/wiki/Wildcard_character) matching.
  14. It matches even across newlines. For example, `foo*r` will match `foo\nbar`.
  15. @param inputs - Strings to match.
  16. @param patterns - Use `*` to match zero or more characters. A pattern starting with `!` will be negated.
  17. @returns The `inputs` filtered based on the `patterns`.
  18. @example
  19. ```
  20. import matcher = require('matcher');
  21. matcher(['foo', 'bar', 'moo'], ['*oo', '!foo']);
  22. //=> ['moo']
  23. matcher(['foo', 'bar', 'moo'], ['!*oo']);
  24. //=> ['bar']
  25. ```
  26. */
  27. (inputs: readonly string[], patterns: readonly string[], options?: matcher.Options): string[];
  28. /**
  29. It matches even across newlines. For example, `foo*r` will match `foo\nbar`.
  30. @param input - String or array of strings to match.
  31. @param pattern - String or array of string patterns. Use `*` to match zero or more characters. A pattern starting with `!` will be negated.
  32. @returns Whether any given `input` matches every given `pattern`.
  33. @example
  34. ```
  35. import matcher = require('matcher');
  36. matcher.isMatch('unicorn', 'uni*');
  37. //=> true
  38. matcher.isMatch('unicorn', '*corn');
  39. //=> true
  40. matcher.isMatch('unicorn', 'un*rn');
  41. //=> true
  42. matcher.isMatch('rainbow', '!unicorn');
  43. //=> true
  44. matcher.isMatch('foo bar baz', 'foo b* b*');
  45. //=> true
  46. matcher.isMatch('unicorn', 'uni\\*');
  47. //=> false
  48. matcher.isMatch('UNICORN', 'UNI*', {caseSensitive: true});
  49. //=> true
  50. matcher.isMatch('UNICORN', 'unicorn', {caseSensitive: true});
  51. //=> false
  52. matcher.isMatch(['foo', 'bar'], 'f*');
  53. //=> true
  54. matcher.isMatch(['foo', 'bar'], ['a*', 'b*']);
  55. //=> true
  56. matcher.isMatch('unicorn', ['tri*', 'UNI*'], {caseSensitive: true});
  57. //=> false
  58. ```
  59. */
  60. isMatch: (input: string | readonly string[], pattern: string | readonly string[], options?: matcher.Options) => boolean;
  61. };
  62. export = matcher;