@@ -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
125
114
## path.isAbsolute(path)
@@ -160,8 +149,7 @@ Example:
160
149
161
150
``` js
162
151
path .join (' /foo' , ' bar' , ' baz/asdf' , ' quux' , ' ..' )
163
- // returns
164
- ' /foo/bar/baz/asdf'
152
+ // returns '/foo/bar/baz/asdf'
165
153
166
154
path .join (' foo' , {}, ' bar' )
167
155
// throws exception
@@ -185,8 +173,7 @@ Example:
185
173
186
174
``` js
187
175
path .normalize (' /foo/bar//baz/asdf/quux/..' )
188
- // returns
189
- ' /foo/bar/baz/asdf'
176
+ // returns '/foo/bar/baz/asdf'
190
177
```
191
178
192
179
* Note:* If the path string passed as argument is a zero-length string then ` '.' `
@@ -201,27 +188,27 @@ An example on \*nix:
201
188
``` js
202
189
path .parse (' /home/user/dir/file.txt' )
203
190
// returns
204
- {
205
- root : " /" ,
206
- dir : " /home/user/dir" ,
207
- base : " file.txt" ,
208
- ext : " .txt" ,
209
- name : " file"
210
- }
191
+ // {
192
+ // root : "/",
193
+ // dir : "/home/user/dir",
194
+ // base : "file.txt",
195
+ // ext : ".txt",
196
+ // name : "file"
197
+ // }
211
198
```
212
199
213
200
An example on Windows:
214
201
215
202
``` js
216
203
path .parse (' C:\\ path\\ dir\\ index.html' )
217
204
// returns
218
- {
219
- root : " C:\\ " ,
220
- dir : " C:\\ path\\ dir" ,
221
- base : " index.html" ,
222
- ext : " .html" ,
223
- name : " index"
224
- }
205
+ // {
206
+ // root : "C:\\",
207
+ // dir : "C:\\path\\dir",
208
+ // base : "index.html",
209
+ // ext : ".html",
210
+ // name : "index"
211
+ // }
225
212
```
226
213
227
214
## path.posix
@@ -245,12 +232,10 @@ Examples:
245
232
246
233
``` js
247
234
path .relative (' C:\\ orandea\\ test\\ aaa' , ' C:\\ orandea\\ impl\\ bbb' )
248
- // returns
249
- ' ..\\ ..\\ impl\\ bbb'
235
+ // returns '..\\..\\impl\\bbb'
250
236
251
237
path .relative (' /data/orandea/test/aaa' , ' /data/orandea/impl/bbb' )
252
- // returns
253
- ' ../../impl/bbb'
238
+ // returns '../../impl/bbb'
254
239
```
255
240
256
241
* Note:* If the arguments to ` relative ` have zero-length strings then the current
@@ -290,16 +275,14 @@ Examples:
290
275
291
276
``` js
292
277
path .resolve (' /foo/bar' , ' ./baz' )
293
- // returns
294
- ' /foo/bar/baz'
278
+ // returns '/foo/bar/baz'
295
279
296
280
path .resolve (' /foo/bar' , ' /tmp/file/' )
297
- // returns
298
- ' /tmp/file'
281
+ // returns '/tmp/file'
299
282
300
283
path .resolve (' wwwroot' , ' static_files/png/' , ' ../gif/image.gif' )
301
284
// if currently in /home/myself/node, it returns
302
- ' /home/myself/node/wwwroot/static_files/gif/image.gif'
285
+ // '/home/myself/node/wwwroot/static_files/gif/image.gif'
303
286
```
304
287
305
288
* Note:* If the arguments to ` resolve ` have zero-length strings then the current
@@ -313,16 +296,14 @@ An example on \*nix:
313
296
314
297
``` js
315
298
' foo/bar/baz' .split (path .sep )
316
- // returns
317
- [' foo' , ' bar' , ' baz' ]
299
+ // returns ['foo', 'bar', 'baz']
318
300
```
319
301
320
302
An example on Windows:
321
303
322
304
``` js
323
305
' foo\\ bar\\ baz' .split (path .sep )
324
- // returns
325
- [' foo' , ' bar' , ' baz' ]
306
+ // returns ['foo', 'bar', 'baz']
326
307
```
327
308
328
309
## path.win32
0 commit comments