index.d.ts 1016 B

123456789101112131415161718192021222324
  1. /**
  2. * Convert a glob pattern to a regular expression
  3. *
  4. * Supports:
  5. * - `/` to separate path segments
  6. * - `*` to match zero or more characters in a path segment
  7. * - `?` to match one character in a path segment
  8. * - `**` to match any number of path segments, including none
  9. * - `{}` to group conditions (e.g. `{html,txt}`)
  10. * - `[abc]`, `[a-z]`, `[!a-z]`, `[!abc]` character classes
  11. */
  12. export declare const toRegex: (pattern: string) => RegExp;
  13. /**
  14. * A glob pattern to match files paths against. An array or a single pattern
  15. * can be provided, if an array is given, then individual patterns will be
  16. * tested in order until one matches (OR short-circuits).
  17. *
  18. * For each pattern a string or a regular expression can be provided. If the
  19. * string starts with `/` and ends with `/<flags>?` it is treated as a regular
  20. * expression.
  21. */
  22. export type Pattern = string | RegExp | (string | RegExp)[];
  23. export type Matcher = (path: string) => boolean;
  24. export declare const toMatcher: (pattern: Pattern) => Matcher;