githrun

A CLI tool to run Python scrip...
Log | Files | Refs | README | LICENSE

path.d.ts (7719B)


      1 declare module "path/posix" {
      2     import path = require("path");
      3     export = path;
      4 }
      5 declare module "path/win32" {
      6     import path = require("path");
      7     export = path;
      8 }
      9 /**
     10  * The `path` module provides utilities for working with file and directory paths.
     11  * It can be accessed using:
     12  *
     13  * ```js
     14  * import path from 'node:path';
     15  * ```
     16  * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/path.js)
     17  */
     18 declare module "path" {
     19     namespace path {
     20         /**
     21          * A parsed path object generated by path.parse() or consumed by path.format().
     22          */
     23         interface ParsedPath {
     24             /**
     25              * The root of the path such as '/' or 'c:\'
     26              */
     27             root: string;
     28             /**
     29              * The full directory path such as '/home/user/dir' or 'c:\path\dir'
     30              */
     31             dir: string;
     32             /**
     33              * The file name including extension (if any) such as 'index.html'
     34              */
     35             base: string;
     36             /**
     37              * The file extension (if any) such as '.html'
     38              */
     39             ext: string;
     40             /**
     41              * The file name without extension (if any) such as 'index'
     42              */
     43             name: string;
     44         }
     45         interface FormatInputPathObject {
     46             /**
     47              * The root of the path such as '/' or 'c:\'
     48              */
     49             root?: string | undefined;
     50             /**
     51              * The full directory path such as '/home/user/dir' or 'c:\path\dir'
     52              */
     53             dir?: string | undefined;
     54             /**
     55              * The file name including extension (if any) such as 'index.html'
     56              */
     57             base?: string | undefined;
     58             /**
     59              * The file extension (if any) such as '.html'
     60              */
     61             ext?: string | undefined;
     62             /**
     63              * The file name without extension (if any) such as 'index'
     64              */
     65             name?: string | undefined;
     66         }
     67         interface PlatformPath {
     68             /**
     69              * Normalize a string path, reducing '..' and '.' parts.
     70              * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
     71              *
     72              * @param path string path to normalize.
     73              * @throws {TypeError} if `path` is not a string.
     74              */
     75             normalize(path: string): string;
     76             /**
     77              * Join all arguments together and normalize the resulting path.
     78              *
     79              * @param paths paths to join.
     80              * @throws {TypeError} if any of the path segments is not a string.
     81              */
     82             join(...paths: string[]): string;
     83             /**
     84              * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
     85              *
     86              * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
     87              *
     88              * If {to} isn't already absolute, {from} arguments are prepended in right to left order,
     89              * until an absolute path is found. If after using all {from} paths still no absolute path is found,
     90              * the current working directory is used as well. The resulting path is normalized,
     91              * and trailing slashes are removed unless the path gets resolved to the root directory.
     92              *
     93              * @param paths string paths to join.
     94              * @throws {TypeError} if any of the arguments is not a string.
     95              */
     96             resolve(...paths: string[]): string;
     97             /**
     98              * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
     99              *
    100              * If the given {path} is a zero-length string, `false` will be returned.
    101              *
    102              * @param path path to test.
    103              * @throws {TypeError} if `path` is not a string.
    104              */
    105             isAbsolute(path: string): boolean;
    106             /**
    107              * Solve the relative path from {from} to {to} based on the current working directory.
    108              * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
    109              *
    110              * @throws {TypeError} if either `from` or `to` is not a string.
    111              */
    112             relative(from: string, to: string): string;
    113             /**
    114              * Return the directory name of a path. Similar to the Unix dirname command.
    115              *
    116              * @param path the path to evaluate.
    117              * @throws {TypeError} if `path` is not a string.
    118              */
    119             dirname(path: string): string;
    120             /**
    121              * Return the last portion of a path. Similar to the Unix basename command.
    122              * Often used to extract the file name from a fully qualified path.
    123              *
    124              * @param path the path to evaluate.
    125              * @param ext optionally, an extension to remove from the result.
    126              * @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string.
    127              */
    128             basename(path: string, ext?: string): string;
    129             /**
    130              * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
    131              * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
    132              *
    133              * @param path the path to evaluate.
    134              * @throws {TypeError} if `path` is not a string.
    135              */
    136             extname(path: string): string;
    137             /**
    138              * The platform-specific file separator. '\\' or '/'.
    139              */
    140             readonly sep: "\\" | "/";
    141             /**
    142              * The platform-specific file delimiter. ';' or ':'.
    143              */
    144             readonly delimiter: ";" | ":";
    145             /**
    146              * Returns an object from a path string - the opposite of format().
    147              *
    148              * @param path path to evaluate.
    149              * @throws {TypeError} if `path` is not a string.
    150              */
    151             parse(path: string): ParsedPath;
    152             /**
    153              * Returns a path string from an object - the opposite of parse().
    154              *
    155              * @param pathObject path to evaluate.
    156              */
    157             format(pathObject: FormatInputPathObject): string;
    158             /**
    159              * On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
    160              * If path is not a string, path will be returned without modifications.
    161              * This method is meaningful only on Windows system.
    162              * On POSIX systems, the method is non-operational and always returns path without modifications.
    163              */
    164             toNamespacedPath(path: string): string;
    165             /**
    166              * Posix specific pathing.
    167              * Same as parent object on posix.
    168              */
    169             readonly posix: PlatformPath;
    170             /**
    171              * Windows specific pathing.
    172              * Same as parent object on windows
    173              */
    174             readonly win32: PlatformPath;
    175         }
    176     }
    177     const path: path.PlatformPath;
    178     export = path;
    179 }
    180 declare module "node:path" {
    181     import path = require("path");
    182     export = path;
    183 }
    184 declare module "node:path/posix" {
    185     import path = require("path/posix");
    186     export = path;
    187 }
    188 declare module "node:path/win32" {
    189     import path = require("path/win32");
    190     export = path;
    191 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror