MCPcopy Create free account
hub / github.com/Effect-TS/effect / globToRegExp

Function globToRegExp

packages/tools/jsdocs/src/Jsdocs.ts:510–529  ·  view source on GitHub ↗
(glob: string)

Source from the content-addressed store, hash-verified

508}
509
510function globToRegExp(glob: string): RegExp {
511 let source = "^"
512 for (let index = 0; index < glob.length; index++) {
513 const char = glob[index]
514 const next = glob[index + 1]
515 if (char === "*") {
516 if (next === "*") {
517 source += ".*"
518 index++
519 } else {
520 source += "[^/]*"
521 }
522 } else if (char === "?") {
523 source += "[^/]"
524 } else {
525 source += escapeRegExp(char)
526 }
527 }
528 return new RegExp(`${source}$`)
529}
530
531/**
532 * Creates a predicate that checks whether a filename is included by the configured JSDoc globs.

Callers

nothing calls this directly

Calls 1

escapeRegExpFunction · 0.70

Tested by

no test coverage detected