/** * @copyright Sister Software * @license MIT * @author Teffen Ellis, et al. */ import type { PluckBasename } from "./basename.js"; import { type PluckDirname } from "./dirname.js"; import type { PluckBaseFileName, PluckFileExtension } from "./extname.js"; import { PathBuilder } from "./path-builder.js"; /** * Returns an object from a path string - the opposite of format(). * * @param path Path to evaluate. * * @returns A parsed path object. * @throws {TypeError} If path is not a string or {@linkcode PathBuilder}. * @see {@linkcode ParsedPath} for the object returned. */ export declare function parse(path: T): T extends PathBuilder ? ParsedPath : T extends string ? ParsedPath : never; /** * Pluck the root of a path. */ export type PathRoot = T extends `/${string}` ? "/" : ""; /** The `dir` field returned by `path.posix.parse`, which is empty for a path with no directory portion. */ export type PluckParsedDirname = PluckDirname extends "." ? "" : PluckDirname; /** * A parsed path object generated by path.parse() or consumed by path.format(). * * @see {@linkcode parse} to create a ParsedPath object. * @see {@linkcode format} to consume a ParsedPath object. */ export interface ParsedPath { /** * The POSIX root of the path, when present. */ root: PathRoot; /** * The full directory path such as '/home/user/dir', or an empty string when none is present. */ dir: PluckParsedDirname; /** * The file name including extension (if any) such as 'index.html' */ base: PluckBasename; /** * The file name without extension (if any) such as 'index' */ name: PluckBaseFileName; /** * The file extension (if any) such as '.html' */ ext: PluckFileExtension; } export default parse; //# sourceMappingURL=parse.d.ts.map