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

Function createJSDocFileMatcher

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

Source from the content-addressed store, hash-verified

535 * @since 4.0.0
536 */
537export function createJSDocFileMatcher(options: {
538 readonly cwd: string
539 readonly include?: ReadonlyArray<string>
540 readonly exclude?: ReadonlyArray<string>
541}): (filename: string) => boolean {
542 const include = options.include?.map(globToRegExp)
543 const exclude = options.exclude?.map(globToRegExp)
544 return (filename) => {
545 const normalizedFilename = normalizePathName(filename)
546 const relativeFilename = normalizePathName(path.relative(options.cwd, filename))
547 const matches = (regexp: RegExp) => regexp.test(normalizedFilename) || regexp.test(relativeFilename)
548 if (include !== undefined && !include.some(matches)) {
549 return false
550 }
551 if (exclude !== undefined && exclude.some(matches)) {
552 return false
553 }
554 return true
555 }
556}
557
558function isRecord(value: unknown): value is Record<string, unknown> {
559 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