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

Function createJSDocFileMatcher

packages/tools/jsdocs/src/Jsdocs.ts:523–542  ·  view source on GitHub ↗
(options: {
  readonly cwd: string
  readonly include?: ReadonlyArray<string>
  readonly exclude?: ReadonlyArray<string>
})

Source from the content-addressed store, hash-verified

521 * @since 4.0.0
522 */
523export function createJSDocFileMatcher(options: {
524 readonly cwd: string
525 readonly include?: ReadonlyArray<string>
526 readonly exclude?: ReadonlyArray<string>
527}): (filename: string) => boolean {
528 const include = options.include?.map(globToRegExp)
529 const exclude = options.exclude?.map(globToRegExp)
530 return (filename) => {
531 const normalizedFilename = normalizePathName(filename)
532 const relativeFilename = normalizePathName(path.relative(options.cwd, filename))
533 const matches = (regexp: RegExp) => regexp.test(normalizedFilename) || regexp.test(relativeFilename)
534 if (include !== undefined && !include.some(matches)) {
535 return false
536 }
537 if (exclude !== undefined && exclude.some(matches)) {
538 return false
539 }
540 return true
541 }
542}
543
544function isRecord(value: unknown): value is Record<string, unknown> {
545 return typeof value === "object" && value !== null && !Array.isArray(value)

Callers

nothing calls this directly

Calls 3

someMethod · 0.80
normalizePathNameFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected