/// /// import type { Stats } from 'fs'; import type { Pathy } from './pathy.js'; import type { FileRetryOptions, PathyFindParentOptions, PathyInfix, PathyListChildrenOptions, PathyOrString, PathyReadOptions, PathyReadOutput, PathySchema, PathyWriteOptions } from './pathy.types.js'; /** * A base class providing static functions for {@link Pathy}. * Can be used on its own if you want to make use of Pathy * normalization and methods while only using strings (instead * of Pathy instances). */ export declare class PathyStatic { /** * Normalize a path to posix-style separators and trim * trailing slashes. * * This provides better portability of paths across platforms, * and ensures that the same path always normalizes to the same * string value. */ static normalize(path: PathyOrString): string; /** * Replace the current path separators * withs something else. Defaults to the * separator of the current platform. */ static replaceSeparator(path: string, separator?: "/" | "\\"): string; static basename(path: PathyOrString): string; /** * Check if a path has the given extension, ignoring case * and ensuring the `.` is present even if not provided in * the args (since that's always confusing). */ static hasExtension(path: PathyOrString, ext: string): boolean; /** * Instead of parsing a file as `{name}{.ext}`, * also parse out the infix if present: `{name}{.infix}{.ext}`. */ static parseInfix(path: PathyOrString): PathyInfix; static removeInfix(path: PathyOrString): string; /** * Explode a path by splitting on the path separator. * Basically the opposite of {@link join}. * * Maintains consistent array length between relative and * absolute paths by having the first element be `'/'` * for absolute paths and `''` (nullstring) for * relative paths. * * @example * PathyStatic.explode('/a/b/c.js'); * // ['/','a','b','c.js'] * PathyStatic.explode('a/b/c.js'); * // ['','a','b','c.js'] */ static explode(path: PathyOrString): string[]; /** * Compare to paths, returning a number indicating their relative * sort order based on their parts. This is useful for semantically * sorting paths so that those in the same folder heirarchy are grouped * together, and those with similar depth are grouped near each other. */ static compare(path1: PathyOrString, path2: PathyOrString): number; /** * Get all parent paths eventually leading to a given * path. * * @example * // Absolute * PathyStatic.lineage("/a/b/c.js"); * // [ * // "/", * // "/a", * // "/a/b", * // "/a/b/c.js", * // ] * * // Relative * PathyStatic.lineage("a/b/c.js"); * // [ * // "", * // "a", * // "a/b", * // "a/b/c.js", * // ] */ static lineage(path: PathyOrString): string[]; static isAbsolute(path: PathyOrString): boolean; static isRelative(path: PathyOrString): boolean; static ensureAbsolute(path: PathyOrString, cwd?: PathyOrString): string; static join(...paths: PathyOrString[]): string; static resolve(...paths: PathyOrString[]): string; static resolveRelative(from: PathyOrString, to: PathyOrString): string; /** * For two paths, represented as strings or Pathy instances, * returns `true` if their normalized paths are equal. * * @example * const p1 = new Pathy('/foo/bar'); * Pathy.isSamePath(p1,'/foo/bar'); // true */ static equals(firstPath: PathyOrString, otherPath: PathyOrString): boolean; /** * Given a collection of paths, determine their * common branch point (the directory at which they * stop sharing their path components). * * **NOTE:** take care to ensure that all paths are * relative to the same root, e.g. due to being * absolute or relative to the same cwd. Otherwise * you'll get unexpected results. */ static findBranchPoint(...paths: PathyOrString[]): string; /** * Determine if one path is the parent of another. * * Returns `true` if `parent` is a parent of `child`, * or if both are the same path. */ static isParentOf(parent: PathyOrString, child: PathyOrString): boolean; static listChildrenRecursively(dir: Pathy, options?: PathyListChildrenOptions): Promise; /** * Starting in the `startDir`, work up the directory tree * looking for a file that matches `basename` in each * parent directory. */ static findParentPath(from: Pathy, basename: string, options?: PathyFindParentOptions): Promise; static findParentPathSync(from: Pathy, basename: string, options?: PathyFindParentOptions): Pathy | undefined; /** * For file extensions that indicate identical or similar * content serialization, get a normalized extension. This * is useful for simplifying parser/serializer lookups. * * Currently only supports JSON and YAML extensions. */ static normalizedExtension(filepath: PathyOrString): string | undefined; static stat(filepath: PathyOrString, options?: FileRetryOptions): Promise; static exists(filepath: PathyOrString, options?: FileRetryOptions): Promise; /** * Write data to file, using the extension to determine * the serialization method. * * If the incoming data is a string, it is already assumed * to be serialized when writing to JSON or YAML. */ static write(filepath: PathyOrString, data: any, options?: PathyWriteOptions): Promise; /** * Read the file at a given path, automatically parsing * it if the extension is supported (parsing can be customized). */ static read | never = never>(filepath: PathyOrString, options?: PathyReadOptions): Promise>; static get defaultIgnoredDirs(): readonly ["node_modules", ".git", ".hg", ".svn", ".idea", ".vscode", ".vscode-test"]; } //# sourceMappingURL=pathy.static.d.ts.map