Skip to content

compareGlobPathMatches

compareGlobPathMatches(left, right): number

Defined in: packages/format-glob/src/compile-glob-path.ts:208

Which of two matching patterns is the more specific, most specific first.

An exact strict weak ordering — no tolerance and no “close enough” tier — so it is safe to sort, bisect or heap with. The ranking every configuration overlay ends up needing:

  1. By kind: exact text, then in-segment globs, then *, then **, then any mixture of those, which is the least specific thing a pattern can be;
  2. Between two patterns holding a single * and nothing else, the one whose * is rightmost — a trailing wildcard constrains more of the path;
  3. Fewer special segments;
  4. More segments, since each one is another constraint;
  5. Fewer **.

Two patterns that tie on all five are genuinely equivalent for precedence, and the caller’s own order decides between them.

GlobPathMatch

GlobPathMatch

number