MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / pathStem

Function pathStem

src/db/reference-tail.ts:109–114  ·  view source on GitHub ↗

A path's last segment up to its first dot — `./pages/Team` → 'Team', `a/b.dart` → 'b' — or '' when that is only dots.

(path: string)

Source from the content-addressed store, hash-verified

107
108/** A path's last segment up to its first dot — `./pages/Team` → 'Team', `a/b.dart` → 'b' — or '' when that is only dots. */
109function pathStem(path: string): string {
110 const trimmed = path.replace(/\/+$/, '');
111 const stem = fileNameStem(trimmed.slice(trimmed.lastIndexOf('/') + 1));
112 // `..` and `.` name a folder only through the referring file's location.
113 return /^\.*$/.test(stem) ? '' : stem;
114}
115
116/** A file or folder name up to its first dot: 'b.dart' → 'b', 'types.d.ts' → 'types', '.eslintrc.js' → '.eslintrc'. */
117function fileNameStem(name: string): string {

Callers 2

referenceNameTailFunction · 0.85
moduleTailFunction · 0.85

Calls 1

fileNameStemFunction · 0.85

Tested by

no test coverage detected