@@ -16,12 +16,10 @@ Example:
16
16
17
17
``` js
18
18
path .basename (' /foo/bar/baz/asdf/quux.html' )
19
- // returns
20
- ' quux.html'
19
+ // returns 'quux.html'
21
20
22
21
path .basename (' /foo/bar/baz/asdf/quux.html' , ' .html' )
23
- // returns
24
- ' quux'
22
+ // returns 'quux'
25
23
```
26
24
27
25
## path.delimiter
@@ -35,8 +33,7 @@ console.log(process.env.PATH)
35
33
// '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'
36
34
37
35
process .env .PATH .split (path .delimiter )
38
- // returns
39
- [' /usr/bin' , ' /bin' , ' /usr/sbin' , ' /sbin' , ' /usr/local/bin' ]
36
+ // returns ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']
40
37
```
41
38
42
39
An example on Windows:
@@ -46,8 +43,7 @@ console.log(process.env.PATH)
46
43
// 'C:\Windows\system32;C:\Windows;C:\Program Files\node\'
47
44
48
45
process .env .PATH .split (path .delimiter )
49
- // returns
50
- [' C:\\ Windows\\ system32' , ' C:\\ Windows' , ' C:\\ Program Files\\ node\\ ' ]
46
+ // returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
51
47
```
52
48
53
49
## path.dirname(p)
@@ -58,8 +54,7 @@ Example:
58
54
59
55
``` js
60
56
path .dirname (' /foo/bar/baz/asdf/quux' )
61
- // returns
62
- ' /foo/bar/baz/asdf'
57
+ // returns '/foo/bar/baz/asdf'
63
58
```
64
59
65
60
## path.extname(p)
@@ -71,24 +66,19 @@ an empty string. Examples:
71
66
72
67
``` js
73
68
path .extname (' index.html' )
74
- // returns
75
- ' .html'
69
+ // returns '.html'
76
70
77
71
path .extname (' index.coffee.md' )
78
- // returns
79
- ' .md'
72
+ // returns '.md'
80
73
81
74
path .extname (' index.' )
82
- // returns
83
- ' .'
75
+ // returns '.'
84
76
85
77
path .extname (' index' )
86
- // returns
87
- ' '
78
+ // returns ''
88
79
89
80
path .extname (' .index' )
90
- // returns
91
- ' '
81
+ // returns ''
92
82
```
93
83
94
84
## path.format(pathObject)
@@ -117,9 +107,8 @@ path.format({
117
107
base : " file.txt" ,
118
108
ext : " .txt" ,
119
109
name : " file"
120
- })
121
- // returns
122
- ' /home/user/dir/file.txt'
110
+ });
111
+ // returns '/home/user/dir/file.txt'
123
112
124
113
// `root` will be used if `dir` is not specified and `name` + `ext` will be used
125
114
// if `base` is not specified
@@ -128,8 +117,7 @@ path.format({
128
117
ext : " .txt" ,
129
118
name : " file"
130
119
})
131
- // returns
132
- ' /file.txt'
120
+ // returns '/file.txt'
133
121
```
134
122
135
123
## path.isAbsolute(path)
@@ -170,8 +158,7 @@ Example:
170
158
171
159
``` js
172
160
path .join (' /foo' , ' bar' , ' baz/asdf' , ' quux' , ' ..' )
173
- // returns
174
- ' /foo/bar/baz/asdf'
161
+ // returns '/foo/bar/baz/asdf'
175
162
176
163
path .join (' foo' , {}, ' bar' )
177
164
// throws exception
@@ -195,8 +182,7 @@ Example:
195
182
196
183
``` js
197
184
path .normalize (' /foo/bar//baz/asdf/quux/..' )
198
- // returns
199
- ' /foo/bar/baz/asdf'
185
+ // returns '/foo/bar/baz/asdf'
200
186
```
201
187
202
188
* Note:* If the path string passed as argument is a zero-length string then ` '.' `
@@ -211,27 +197,27 @@ An example on \*nix:
211
197
``` js
212
198
path .parse (' /home/user/dir/file.txt' )
213
199
// returns
214
- {
215
- root : " /" ,
216
- dir : " /home/user/dir" ,
217
- base : " file.txt" ,
218
- ext : " .txt" ,
219
- name : " file"
220
- }
200
+ // {
201
+ // root : "/",
202
+ // dir : "/home/user/dir",
203
+ // base : "file.txt",
204
+ // ext : ".txt",
205
+ // name : "file"
206
+ // }
221
207
```
222
208
223
209
An example on Windows:
224
210
225
211
``` js
226
212
path .parse (' C:\\ path\\ dir\\ index.html' )
227
213
// returns
228
- {
229
- root : " C:\\ " ,
230
- dir : " C:\\ path\\ dir" ,
231
- base : " index.html" ,
232
- ext : " .html" ,
233
- name : " index"
234
- }
214
+ // {
215
+ // root : "C:\\",
216
+ // dir : "C:\\path\\dir",
217
+ // base : "index.html",
218
+ // ext : ".html",
219
+ // name : "index"
220
+ // }
235
221
```
236
222
237
223
## path.posix
@@ -255,12 +241,10 @@ Examples:
255
241
256
242
``` js
257
243
path .relative (' C:\\ orandea\\ test\\ aaa' , ' C:\\ orandea\\ impl\\ bbb' )
258
- // returns
259
- ' ..\\ ..\\ impl\\ bbb'
244
+ // returns '..\\..\\impl\\bbb'
260
245
261
246
path .relative (' /data/orandea/test/aaa' , ' /data/orandea/impl/bbb' )
262
- // returns
263
- ' ../../impl/bbb'
247
+ // returns '../../impl/bbb'
264
248
```
265
249
266
250
* Note:* If the arguments to ` relative ` have zero-length strings then the current
@@ -300,16 +284,14 @@ Examples:
300
284
301
285
``` js
302
286
path .resolve (' /foo/bar' , ' ./baz' )
303
- // returns
304
- ' /foo/bar/baz'
287
+ // returns '/foo/bar/baz'
305
288
306
289
path .resolve (' /foo/bar' , ' /tmp/file/' )
307
- // returns
308
- ' /tmp/file'
290
+ // returns '/tmp/file'
309
291
310
292
path .resolve (' wwwroot' , ' static_files/png/' , ' ../gif/image.gif' )
311
293
// if currently in /home/myself/node, it returns
312
- ' /home/myself/node/wwwroot/static_files/gif/image.gif'
294
+ // '/home/myself/node/wwwroot/static_files/gif/image.gif'
313
295
```
314
296
315
297
* Note:* If the arguments to ` resolve ` have zero-length strings then the current
@@ -323,16 +305,14 @@ An example on \*nix:
323
305
324
306
``` js
325
307
' foo/bar/baz' .split (path .sep )
326
- // returns
327
- [' foo' , ' bar' , ' baz' ]
308
+ // returns ['foo', 'bar', 'baz']
328
309
```
329
310
330
311
An example on Windows:
331
312
332
313
``` js
333
314
' foo\\ bar\\ baz' .split (path .sep )
334
- // returns
335
- [' foo' , ' bar' , ' baz' ]
315
+ // returns ['foo', 'bar', 'baz']
336
316
```
337
317
338
318
## path.win32
0 commit comments