globsToMatcher.d.ts 1.0 KB

123456789101112131415161718192021222324252627
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. import type { Config } from '@jest/types';
  8. declare type Matcher = (str: Config.Path) => boolean;
  9. /**
  10. * Converts a list of globs into a function that matches a path against the
  11. * globs.
  12. *
  13. * Every time micromatch is called, it will parse the glob strings and turn
  14. * them into regexp instances. Instead of calling micromatch repeatedly with
  15. * the same globs, we can use this function which will build the micromatch
  16. * matchers ahead of time and then have an optimized path for determining
  17. * whether an individual path matches.
  18. *
  19. * This function is intended to match the behavior of `micromatch()`.
  20. *
  21. * @example
  22. * const isMatch = globsToMatcher(['*.js', '!*.test.js']);
  23. * isMatch('pizza.js'); // true
  24. * isMatch('pizza.test.js'); // false
  25. */
  26. export default function globsToMatcher(globs: Array<Config.Glob>): Matcher;
  27. export {};