@@ -8,6 +8,9 @@ paths. The file system is not consulted to check whether paths are valid.
8
8
Use ` require('path') ` to use this module. The following methods are provided:
9
9
10
10
## path.basename(path[ , ext] )
11
+ <!-- YAML
12
+ added: v0.1.25
13
+ -->
11
14
12
15
Return the last portion of a path, similar to the Unix ` basename ` command.
13
16
` path ` must be a string. ` ext ` , if given, must also be a string.
@@ -23,6 +26,9 @@ path.basename('/foo/bar/baz/asdf/quux.html', '.html')
23
26
```
24
27
25
28
## path.delimiter
29
+ <!-- YAML
30
+ added: v0.9.3
31
+ -->
26
32
27
33
The platform-specific path delimiter, ` ; ` or ` ':' ` .
28
34
@@ -47,6 +53,9 @@ process.env.PATH.split(path.delimiter)
47
53
```
48
54
49
55
## path.dirname(path)
56
+ <!-- YAML
57
+ added: v0.1.16
58
+ -->
50
59
51
60
Return the directory name of a path, similar to the Unix ` dirname ` command.
52
61
` path ` must be a string.
@@ -59,6 +68,9 @@ path.dirname('/foo/bar/baz/asdf/quux')
59
68
```
60
69
61
70
## path.extname(path)
71
+ <!-- YAML
72
+ added: v0.1.25
73
+ -->
62
74
63
75
Return the extension of the path, from the last '.' to end of string
64
76
in the last portion of the path. If there is no '.' in the last portion
@@ -85,6 +97,9 @@ path.extname('.index')
85
97
```
86
98
87
99
## path.format(pathObject)
100
+ <!-- YAML
101
+ added: v0.11.15
102
+ -->
88
103
89
104
Returns a path string from an object. This is the opposite of [ ` path.parse ` ] [ ] .
90
105
@@ -154,6 +169,9 @@ path.format({
154
169
```
155
170
156
171
## path.isAbsolute(path)
172
+ <!-- YAML
173
+ added: v0.11.2
174
+ -->
157
175
158
176
Determines whether ` path ` is an absolute path. An absolute path will always
159
177
resolve to the same location, regardless of the working directory. ` path ` must
@@ -182,6 +200,9 @@ path.isAbsolute('.') // false
182
200
returned.
183
201
184
202
## path.join([ path1] [ , path2 ] [ , ...] )
203
+ <!-- YAML
204
+ added: v0.1.16
205
+ -->
185
206
186
207
Join all arguments together and normalize the resulting path.
187
208
@@ -205,6 +226,9 @@ TypeError: Arguments to path.join must be strings
205
226
current working directory.
206
227
207
228
## path.normalize(path)
229
+ <!-- YAML
230
+ added: v0.1.23
231
+ -->
208
232
209
233
Normalize a path, taking care of ` '..' ` and ` '.' ` parts. ` path ` must be a
210
234
string.
@@ -224,6 +248,9 @@ path.normalize('/foo/bar//baz/asdf/quux/..')
224
248
will be returned, which represents the current working directory.
225
249
226
250
## path.parse(path)
251
+ <!-- YAML
252
+ added: v0.11.15
253
+ -->
227
254
228
255
Returns an object from a path. ` path ` must be a string.
229
256
@@ -256,11 +283,17 @@ path.parse('C:\\path\\dir\\index.html')
256
283
```
257
284
258
285
## path.posix
286
+ <!-- YAML
287
+ added: v0.11.15
288
+ -->
259
289
260
290
Provide access to aforementioned ` path ` methods but always interact in a posix
261
291
compatible way.
262
292
263
293
## path.relative(from, to)
294
+ <!-- YAML
295
+ added: v0.5.0
296
+ -->
264
297
265
298
Solve the relative path from ` from ` to ` to ` . ` from ` and ` to ` must be strings.
266
299
@@ -287,6 +320,9 @@ path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
287
320
both the paths are the same then a zero-length string will be returned.
288
321
289
322
## path.resolve([ from ...] , to)
323
+ <!-- YAML
324
+ added: v0.3.4
325
+ -->
290
326
291
327
Resolves ` to ` to an absolute path. All arguments must be strings.
292
328
@@ -331,6 +367,9 @@ path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
331
367
```
332
368
333
369
## path.sep
370
+ <!-- YAML
371
+ added: v0.7.9
372
+ -->
334
373
335
374
The platform-specific file separator. ` '\\' ` or ` '/' ` .
336
375
@@ -349,6 +388,9 @@ An example on Windows:
349
388
```
350
389
351
390
## path.win32
391
+ <!-- YAML
392
+ added: v0.11.15
393
+ -->
352
394
353
395
Provide access to aforementioned ` path ` methods but always interact in a win32
354
396
compatible way.
0 commit comments