summaryrefslogtreecommitdiff
path: root/doc/api/path.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/path.md')
-rw-r--r--doc/api/path.md74
1 files changed, 37 insertions, 37 deletions
diff --git a/doc/api/path.md b/doc/api/path.md
index a6f1701261..d9452b00db 100644
--- a/doc/api/path.md
+++ b/doc/api/path.md
@@ -74,10 +74,10 @@ the Unix `basename` command. Trailing directory separators are ignored, see
For example:
```js
-path.basename('/foo/bar/baz/asdf/quux.html')
+path.basename('/foo/bar/baz/asdf/quux.html');
// Returns: 'quux.html'
-path.basename('/foo/bar/baz/asdf/quux.html', '.html')
+path.basename('/foo/bar/baz/asdf/quux.html', '.html');
// Returns: 'quux'
```
@@ -99,21 +99,21 @@ Provides the platform-specific path delimiter:
For example, on POSIX:
```js
-console.log(process.env.PATH)
+console.log(process.env.PATH);
// Prints: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'
-process.env.PATH.split(path.delimiter)
+process.env.PATH.split(path.delimiter);
// Returns: ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']
```
On Windows:
```js
-console.log(process.env.PATH)
+console.log(process.env.PATH);
// Prints: 'C:\Windows\system32;C:\Windows;C:\Program Files\node\'
-process.env.PATH.split(path.delimiter)
-// Returns: ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
+process.env.PATH.split(path.delimiter);
+// Returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
```
## path.dirname(path)
@@ -135,7 +135,7 @@ the Unix `dirname` command. Trailing directory separators are ignored, see
For example:
```js
-path.dirname('/foo/bar/baz/asdf/quux')
+path.dirname('/foo/bar/baz/asdf/quux');
// Returns: '/foo/bar/baz/asdf'
```
@@ -162,19 +162,19 @@ an empty string is returned.
For example:
```js
-path.extname('index.html')
+path.extname('index.html');
// Returns: '.html'
-path.extname('index.coffee.md')
+path.extname('index.coffee.md');
// Returns: '.md'
-path.extname('index.')
+path.extname('index.');
// Returns: '.'
-path.extname('index')
+path.extname('index');
// Returns: ''
-path.extname('.index')
+path.extname('.index');
// Returns: ''
```
@@ -259,22 +259,22 @@ If the given `path` is a zero-length string, `false` will be returned.
For example on POSIX:
```js
-path.isAbsolute('/foo/bar') // true
-path.isAbsolute('/baz/..') // true
-path.isAbsolute('qux/') // false
-path.isAbsolute('.') // false
+path.isAbsolute('/foo/bar'); // true
+path.isAbsolute('/baz/..'); // true
+path.isAbsolute('qux/'); // false
+path.isAbsolute('.'); // false
```
On Windows:
```js
-path.isAbsolute('//server') // true
-path.isAbsolute('\\\\server') // true
-path.isAbsolute('C:/foo/..') // true
-path.isAbsolute('C:\\foo\\..') // true
-path.isAbsolute('bar\\baz') // false
-path.isAbsolute('bar/baz') // false
-path.isAbsolute('.') // false
+path.isAbsolute('//server'); // true
+path.isAbsolute('\\\\server'); // true
+path.isAbsolute('C:/foo/..'); // true
+path.isAbsolute('C:\\foo\\..'); // true
+path.isAbsolute('bar\\baz'); // false
+path.isAbsolute('bar/baz'); // false
+path.isAbsolute('.'); // false
```
A [`TypeError`][] is thrown if `path` is not a string.
@@ -297,10 +297,10 @@ working directory.
For example:
```js
-path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
+path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
// Returns: '/foo/bar/baz/asdf'
-path.join('foo', {}, 'bar')
+path.join('foo', {}, 'bar');
// throws 'TypeError: Path must be a string. Received {}'
```
@@ -327,14 +327,14 @@ current working directory.
For example on POSIX:
```js
-path.normalize('/foo/bar//baz/asdf/quux/..')
+path.normalize('/foo/bar//baz/asdf/quux/..');
// Returns: '/foo/bar/baz/asdf'
```
On Windows:
```js
-path.normalize('C:\\temp\\\\foo\\bar\\..\\')
+path.normalize('C:\\temp\\\\foo\\bar\\..\\');
// Returns: 'C:\\temp\\foo\\'
```
@@ -363,7 +363,7 @@ The returned object will have the following properties:
For example on POSIX:
```js
-path.parse('/home/user/dir/file.txt')
+path.parse('/home/user/dir/file.txt');
// Returns:
// { root: '/',
// dir: '/home/user/dir',
@@ -385,7 +385,7 @@ path.parse('/home/user/dir/file.txt')
On Windows:
```js
-path.parse('C:\\path\\dir\\file.txt')
+path.parse('C:\\path\\dir\\file.txt');
// Returns:
// { root: 'C:\\',
// dir: 'C:\\path\\dir',
@@ -440,14 +440,14 @@ directory will be used instead of the zero-length strings.
For example on POSIX:
```js
-path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
+path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb');
// Returns: '../../impl/bbb'
```
On Windows:
```js
-path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb')
+path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb');
// Returns: '..\\..\\impl\\bbb'
```
@@ -483,13 +483,13 @@ of the current working directory.
For example:
```js
-path.resolve('/foo/bar', './baz')
+path.resolve('/foo/bar', './baz');
// Returns: '/foo/bar/baz'
-path.resolve('/foo/bar', '/tmp/file/')
+path.resolve('/foo/bar', '/tmp/file/');
// Returns: '/tmp/file'
-path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
+path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif');
// if the current working directory is /home/myself/node,
// this returns '/home/myself/node/wwwroot/static_files/gif/image.gif'
```
@@ -511,14 +511,14 @@ Provides the platform-specific path segment separator:
For example on POSIX:
```js
-'foo/bar/baz'.split(path.sep)
+'foo/bar/baz'.split(path.sep);
// Returns: ['foo', 'bar', 'baz']
```
On Windows:
```js
-'foo\\bar\\baz'.split(path.sep)
+'foo\\bar\\baz'.split(path.sep);
// Returns: ['foo', 'bar', 'baz']
```