Skip to content

Commit

Permalink
doc: modernize and fix code examples in path.md
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
vsemozhetbyt authored and evanlucas committed May 2, 2017
1 parent 810f921 commit 43a39c6
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions doc/api/path.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ On Windows:

```js
path.format({
dir : "C:\\path\\dir",
base : "file.txt"
dir: 'C:\\path\\dir',
base: 'file.txt'
});
// Returns: 'C:\\path\\dir\\file.txt'
```
Expand Down Expand Up @@ -299,7 +299,7 @@ path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
// Returns: '/foo/bar/baz/asdf'

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

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

```js
path.normalize('C:\\temp\\\\foo\\bar\\..\\');
path.normalize('C:\\temp\\\\foo\\bar\\..\\')
// Returns: 'C:\\temp\\foo\\'
```

Expand Down Expand Up @@ -362,13 +362,11 @@ For example on POSIX:
```js
path.parse('/home/user/dir/file.txt')
// Returns:
// {
// root : "/",
// dir : "/home/user/dir",
// base : "file.txt",
// ext : ".txt",
// name : "file"
// }
// { root: '/',
// dir: '/home/user/dir',
// base: 'file.txt',
// ext: '.txt',
// name: 'file' }
```

```text
Expand All @@ -386,13 +384,11 @@ On Windows:
```js
path.parse('C:\\path\\dir\\file.txt')
// Returns:
// {
// root : "C:\\",
// dir : "C:\\path\\dir",
// base : "file.txt",
// ext : ".txt",
// name : "file"
// }
// { root: 'C:\\',
// dir: 'C:\\path\\dir',
// base: 'file.txt',
// ext: '.txt',
// name: 'file' }
```

```text
Expand Down

0 comments on commit 43a39c6

Please sign in to comment.