Files
file-one/packages/path/index.ts

19 lines
476 B
TypeScript
Raw Normal View History

2025-09-16 23:17:19 +00:00
export const PATH_SEPARATOR = "/"
export function baseName(path: string): string {
return path.split(PATH_SEPARATOR).pop() ?? ""
}
2025-09-17 00:04:12 +00:00
export function isPathAbsolute(path: string): boolean {
return path.startsWith(PATH_SEPARATOR)
}
2025-09-16 23:17:19 +00:00
export function joinPath(...paths: string[]): string {
return paths.join(PATH_SEPARATOR)
}
2025-09-17 00:04:12 +00:00
export function splitPath(path: string): string[] {
const parts = path.split(PATH_SEPARATOR)
return isPathAbsolute(path) ? parts.slice(1) : parts
}