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

Function globToRegExp

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

Source from the content-addressed store, hash-verified

494}
495
496function globToRegExp(glob: string): RegExp {
497 let source = "^"
498 for (let index = 0; index < glob.length; index++) {
499 const char = glob[index]
500 const next = glob[index + 1]
501 if (char === "*") {
502 if (next === "*") {
503 source += ".*"
504 index++
505 } else {
506 source += "[^/]*"
507 }
508 } else if (char === "?") {
509 source += "[^/]"
510 } else {
511 source += escapeRegExp(char)
512 }
513 }
514 return new RegExp(`${source}$`)
515}
516
517/**
518 * 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