source: trip-planner-front/node_modules/upath/upath.d.ts@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 8.8 KB
RevLine 
[6a3a178]1declare module "upath" {
2
3 /**
4 * A parsed path object generated by path.parse() or consumed by path.format().
5 */
6 export 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 /**
30 * Version of the library
31 */
32 export var VERSION: string;
33
34 /**
35 * Just converts all `to/` and consolidates duplicates, without performing any normalization.
36 *
37 * @param p string path to convert to unix.
38 */
39 export function toUnix(p: string): string;
40
41 /**
42 * Exactly like path.normalize(path), but it keeps the first meaningful ./.
43 *
44 * Note that the unix / is returned everywhere, so windows \ is always converted to unix /.
45 *
46 * @param p string path to normalize.
47 */
48 export function normalizeSafe(p: string): string;
49
50 /**
51 * Exactly like path.normalizeSafe(path), but it trims any useless ending /.
52 *
53 * @param p string path to normalize
54 */
55 export function normalizeTrim(p: string): string;
56
57 /**
58 * Exactly like path.join(), but it keeps the first meaningful ./.
59 *
60 * Note that the unix / is returned everywhere, so windows \ is always converted to unix /.
61 *
62 * @param paths string paths to join
63 */
64 export function joinSafe(...p: any[]): string;
65
66 /**
67 * Adds .ext to filename, but only if it doesn't already have the exact extension.
68 *
69 * @param file string filename to add extension to
70 * @param ext string extension to add
71 */
72 export function addExt(file: string, ext: string): string;
73
74 /**
75 * Trims a filename's extension.
76 *
77 * Extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7).
78 *
79 * An Array of ignoreExts (eg ['.min']) prevents these from being considered as extension, thus are not trimmed.
80 *
81 * @param filename string filename to trim it's extension
82 * @param ignoreExts array extensions to ignore
83 * @param maxSize number max length of the extension
84 */
85 export function trimExt(filename: string, ignoreExts?: string[], maxSize?: number): string;
86
87 /**
88 * Removes the specific ext extension from filename, if it has it. Otherwise it leaves it as is. As in all upath functions, it be .ext or ext.
89 *
90 * @param file string filename to remove extension to
91 * @param ext string extension to remove
92 */
93 export function removeExt(filename: string, ext: string): string;
94
95 /**
96 * Changes a filename's extension to ext. If it has no (valid) extension, it adds it.
97 *
98 * Valid extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7).
99 *
100 * An Array of ignoreExts (eg ['.min']) prevents these from being considered as extension, thus are not changed - the new extension is added instead.
101 *
102 * @param filename string filename to change it's extension
103 * @param ext string extension to change to
104 * @param ignoreExts array extensions to ignore
105 * @param maxSize number max length of the extension
106 */
107 export function changeExt(filename: string, ext: string, ignoreExts?: string[], maxSize?: number): string;
108
109 /**
110 * Adds .ext to filename, only if it doesn't already have any old extension.
111 *
112 * (Old) extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7).
113 *
114 * An Array of ignoreExts (eg ['.min']) will force adding default .ext even if one of these is present.
115 *
116 * @param filename string filename to default to it's extension
117 * @param ext string extension to default to
118 * @param ignoreExts array extensions to ignore
119 * @param maxSize number max length of the extension
120 */
121 export function defaultExt(filename: string, ext: string, ignoreExts?: string[], maxSize?: number): string;
122
123 /**
124 * Normalize a string path, reducing '..' and '.' parts.
125 * 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.
126 *
127 * @param p string path to normalize.
128 */
129 export function normalize(p: string): string;
130 /**
131 * Join all arguments together and normalize the resulting path.
132 * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
133 *
134 * @param paths string paths to join.
135 */
136 export function join(...paths: any[]): string;
137 /**
138 * Join all arguments together and normalize the resulting path.
139 * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
140 *
141 * @param paths string paths to join.
142 */
143 export function join(...paths: string[]): string;
144 /**
145 * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
146 *
147 * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
148 *
149 * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
150 *
151 * @param pathSegments string paths to join. Non-string arguments are ignored.
152 */
153 export function resolve(...pathSegments: any[]): string;
154 /**
155 * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
156 *
157 * @param path path to test.
158 */
159 export function isAbsolute(path: string): boolean;
160 /**
161 * Solve the relative path from {from} to {to}.
162 * 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.
163 *
164 * @param from
165 * @param to
166 */
167 export function relative(from: string, to: string): string;
168 /**
169 * Return the directory name of a path. Similar to the Unix dirname command.
170 *
171 * @param p the path to evaluate.
172 */
173 export function dirname(p: string): string;
174 /**
175 * Return the last portion of a path. Similar to the Unix basename command.
176 * Often used to extract the file name from a fully qualified path.
177 *
178 * @param p the path to evaluate.
179 * @param ext optionally, an extension to remove from the result.
180 */
181 export function basename(p: string, ext?: string): string;
182 /**
183 * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
184 * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
185 *
186 * @param p the path to evaluate.
187 */
188 export function extname(p: string): string;
189 /**
190 * The platform-specific file separator. '\\' or '/'.
191 */
192 export var sep: string;
193 /**
194 * The platform-specific file delimiter. ';' or ':'.
195 */
196 export var delimiter: string;
197 /**
198 * Returns an object from a path string - the opposite of format().
199 *
200 * @param pathString path to evaluate.
201 */
202 export function parse(pathString: string): ParsedPath;
203 /**
204 * Returns a path string from an object - the opposite of parse().
205 *
206 * @param pathString path to evaluate.
207 */
208 export function format(pathObject: ParsedPath): string;
209
210 export module posix {
211 export function normalize(p: string): string;
212 export function join(...paths: any[]): string;
213 export function resolve(...pathSegments: any[]): string;
214 export function isAbsolute(p: string): boolean;
215 export function relative(from: string, to: string): string;
216 export function dirname(p: string): string;
217 export function basename(p: string, ext?: string): string;
218 export function extname(p: string): string;
219 export var sep: string;
220 export var delimiter: string;
221 export function parse(p: string): ParsedPath;
222 export function format(pP: ParsedPath): string;
223 }
224
225 export module win32 {
226 export function normalize(p: string): string;
227 export function join(...paths: any[]): string;
228 export function resolve(...pathSegments: any[]): string;
229 export function isAbsolute(p: string): boolean;
230 export function relative(from: string, to: string): string;
231 export function dirname(p: string): string;
232 export function basename(p: string, ext?: string): string;
233 export function extname(p: string): string;
234 export var sep: string;
235 export var delimiter: string;
236 export function parse(p: string): ParsedPath;
237 export function format(pP: ParsedPath): string;
238 }
239}
Note: See TracBrowser for help on using the repository browser.