Projekt

Obecné

Profil

Stáhnout (6.16 KB) Statistiky
| Větev: | Revize:
1
declare module "path" {
2
    namespace path {
3
        /**
4
         * A parsed path object generated by path.parse() or consumed by path.format().
5
         */
6
        interface ParsedPath {
7
            /**
8
             * The root of the path such as '/' or 'c:\'
9
             */
10
            root: string;
11
            /**
12
             * The full directory path such as '/home/user/dir' or 'c:\path\dir'
13
             */
14
            dir: string;
15
            /**
16
             * The file name including extension (if any) such as 'index.html'
17
             */
18
            base: string;
19
            /**
20
             * The file extension (if any) such as '.html'
21
             */
22
            ext: string;
23
            /**
24
             * The file name without extension (if any) such as 'index'
25
             */
26
            name: string;
27
        }
28

    
29
        interface FormatInputPathObject {
30
            /**
31
             * The root of the path such as '/' or 'c:\'
32
             */
33
            root?: string;
34
            /**
35
             * The full directory path such as '/home/user/dir' or 'c:\path\dir'
36
             */
37
            dir?: string;
38
            /**
39
             * The file name including extension (if any) such as 'index.html'
40
             */
41
            base?: string;
42
            /**
43
             * The file extension (if any) such as '.html'
44
             */
45
            ext?: string;
46
            /**
47
             * The file name without extension (if any) such as 'index'
48
             */
49
            name?: string;
50
        }
51

    
52
        interface PlatformPath {
53
            /**
54
             * Normalize a string path, reducing '..' and '.' parts.
55
             * 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.
56
             *
57
             * @param p string path to normalize.
58
             */
59
            normalize(p: string): string;
60
            /**
61
             * Join all arguments together and normalize the resulting path.
62
             * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
63
             *
64
             * @param paths paths to join.
65
             */
66
            join(...paths: string[]): string;
67
            /**
68
             * The right-most parameter is considered {to}.  Other parameters are considered an array of {from}.
69
             *
70
             * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
71
             *
72
             * If {to} isn't already absolute, {from} arguments are prepended in right to left order,
73
             * until an absolute path is found. If after using all {from} paths still no absolute path is found,
74
             * the current working directory is used as well. The resulting path is normalized,
75
             * and trailing slashes are removed unless the path gets resolved to the root directory.
76
             *
77
             * @param pathSegments string paths to join.  Non-string arguments are ignored.
78
             */
79
            resolve(...pathSegments: string[]): string;
80
            /**
81
             * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
82
             *
83
             * @param path path to test.
84
             */
85
            isAbsolute(p: string): boolean;
86
            /**
87
             * Solve the relative path from {from} to {to}.
88
             * 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.
89
             */
90
            relative(from: string, to: string): string;
91
            /**
92
             * Return the directory name of a path. Similar to the Unix dirname command.
93
             *
94
             * @param p the path to evaluate.
95
             */
96
            dirname(p: string): string;
97
            /**
98
             * Return the last portion of a path. Similar to the Unix basename command.
99
             * Often used to extract the file name from a fully qualified path.
100
             *
101
             * @param p the path to evaluate.
102
             * @param ext optionally, an extension to remove from the result.
103
             */
104
            basename(p: string, ext?: string): string;
105
            /**
106
             * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
107
             * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
108
             *
109
             * @param p the path to evaluate.
110
             */
111
            extname(p: string): string;
112
            /**
113
             * The platform-specific file separator. '\\' or '/'.
114
             */
115
            readonly sep: string;
116
            /**
117
             * The platform-specific file delimiter. ';' or ':'.
118
             */
119
            readonly delimiter: string;
120
            /**
121
             * Returns an object from a path string - the opposite of format().
122
             *
123
             * @param pathString path to evaluate.
124
             */
125
            parse(p: string): ParsedPath;
126
            /**
127
             * Returns a path string from an object - the opposite of parse().
128
             *
129
             * @param pathString path to evaluate.
130
             */
131
            format(pP: FormatInputPathObject): string;
132
            /**
133
             * On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
134
             * If path is not a string, path will be returned without modifications.
135
             * This method is meaningful only on Windows system.
136
             * On POSIX systems, the method is non-operational and always returns path without modifications.
137
             */
138
            toNamespacedPath(path: string): string;
139
            /**
140
             * Posix specific pathing.
141
             * Same as parent object on posix.
142
             */
143
            readonly posix: PlatformPath;
144
            /**
145
             * Windows specific pathing.
146
             * Same as parent object on windows
147
             */
148
            readonly win32: PlatformPath;
149
        }
150
    }
151
    const path: path.PlatformPath;
152
    export = path;
153
}
(27-27/45)