Skip to content

Commit 43a39c6

Browse files
vsemozhetbytevanlucas
authored andcommitted
doc: modernize and fix code examples in path.md
Unify spaces, quotes, and semicolons. Update output examples. PR-URL: #12296 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 810f921 commit 43a39c6

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

doc/api/path.md

+14-18
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ On Windows:
236236

237237
```js
238238
path.format({
239-
dir : "C:\\path\\dir",
240-
base : "file.txt"
239+
dir: 'C:\\path\\dir',
240+
base: 'file.txt'
241241
});
242242
// Returns: 'C:\\path\\dir\\file.txt'
243243
```
@@ -299,7 +299,7 @@ path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
299299
// Returns: '/foo/bar/baz/asdf'
300300

301301
path.join('foo', {}, 'bar')
302-
// throws TypeError: Arguments to path.join must be strings
302+
// throws 'TypeError: Path must be a string. Received {}'
303303
```
304304

305305
A [`TypeError`][] is thrown if any of the path segments is not a string.
@@ -332,7 +332,7 @@ path.normalize('/foo/bar//baz/asdf/quux/..')
332332
On Windows:
333333

334334
```js
335-
path.normalize('C:\\temp\\\\foo\\bar\\..\\');
335+
path.normalize('C:\\temp\\\\foo\\bar\\..\\')
336336
// Returns: 'C:\\temp\\foo\\'
337337
```
338338

@@ -362,13 +362,11 @@ For example on POSIX:
362362
```js
363363
path.parse('/home/user/dir/file.txt')
364364
// Returns:
365-
// {
366-
// root : "/",
367-
// dir : "/home/user/dir",
368-
// base : "file.txt",
369-
// ext : ".txt",
370-
// name : "file"
371-
// }
365+
// { root: '/',
366+
// dir: '/home/user/dir',
367+
// base: 'file.txt',
368+
// ext: '.txt',
369+
// name: 'file' }
372370
```
373371

374372
```text
@@ -386,13 +384,11 @@ On Windows:
386384
```js
387385
path.parse('C:\\path\\dir\\file.txt')
388386
// Returns:
389-
// {
390-
// root : "C:\\",
391-
// dir : "C:\\path\\dir",
392-
// base : "file.txt",
393-
// ext : ".txt",
394-
// name : "file"
395-
// }
387+
// { root: 'C:\\',
388+
// dir: 'C:\\path\\dir',
389+
// base: 'file.txt',
390+
// ext: '.txt',
391+
// name: 'file' }
396392
```
397393

398394
```text

0 commit comments

Comments
 (0)