INNER CODE UNIT · TypeScript

basename

prisma/orm · apps/lsp-playground/src/client/main.ts:131

function basename(path: string): string {
  return path.slice(path.lastIndexOf('/') + 1);
}

/**
 * A member's display label: its path relative to the scratch root. For a
 * flat file this is identical to its basename (no visual change from a
 * plain filename); for a file under a subdirectory it disambiguates members
 * that would otherwise share a basename across sibling directories.
 */
function relativeLabel(path: string, scratchRootPath: string): string {
  const prefix = scratchRootPath.endsWith('/') ? scratchRootPath : `${scratchRootPath}/`;
  return path.startsWith(prefix) ? path.slice(prefix.length) : basename(path);
}

/**
 * One scratch-project member as the client tracks it: its Monaco-facing
 * identity (`uri`/`path`), the text last known for it (the seed text until

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…