export function join(...parts: string[]): string {
  return parts.filter(Boolean).join('/').replace(/\/+/g, '/');
}

export function resolve(...parts: string[]): string {
  return join(...parts);
}

export function dirname(path: string): string {
  const normalized = path.replace(/\/+/g, '/');
  const index = normalized.lastIndexOf('/');
  return index <= 0 ? '.' : normalized.slice(0, index);
}

export function basename(path: string): string {
  const normalized = path.replace(/\/+/g, '/');
  const index = normalized.lastIndexOf('/');
  return index >= 0 ? normalized.slice(index + 1) : normalized;
}

export default {
  join,
  resolve,
  dirname,
  basename,
};
