index.d.ts 1.3 KB

12345678910111213141516171819202122232425262728
  1. /**
  2. * A valid `picomatch` glob pattern, or array of patterns.
  3. */
  4. type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
  5. /**
  6. * Constructs a filter function which can be used to determine whether or not
  7. * certain modules should be operated upon.
  8. * @param include If `include` is omitted or has zero length, filter will return `true` by default.
  9. * @param exclude ID must not match any of the `exclude` patterns.
  10. * @param options Additional options.
  11. * @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
  12. * If a `string` is specified, then the value will be used as the base directory.
  13. * Relative paths will be resolved against `process.cwd()` first.
  14. * If `false`, then the patterns will not be resolved against any directory.
  15. * This can be useful if you want to create a filter for virtual module names.
  16. */
  17. declare function createFilter(include?: FilterPattern, exclude?: FilterPattern, options?: {
  18. resolve?: string | false | null
  19. }): (id: string | unknown) => boolean;
  20. /**
  21. * Converts path separators to forward slash.
  22. */
  23. declare function normalizePath(filename: string): string;
  24. declare function toArray<T>(thing: readonly T[] | T | undefined | null): readonly T[];
  25. export { type FilterPattern, createFilter, normalizePath, toArray };