@ -24,14 +24,14 @@ On POSIX:
```js
path.basename('C:\\temp\\myfile.html');
// returns 'C:\temp\myfile.html'
// Returns: 'C:\temp\myfile.html'
```
On Windows:
```js
path.basename('C:\\temp\\myfile.html');
// returns 'myfile.html'
// Returns: 'myfile.html'
```
To achieve consistent results when working with Windows file paths on any
@ -41,7 +41,7 @@ On POSIX and Windows:
```js
path.win32.basename('C:\\temp\\myfile.html');
// returns 'myfile.html'
// Returns: 'myfile.html'
```
To achieve consistent results when working with POSIX file paths on any
@ -51,7 +51,7 @@ On POSIX and Windows:
```js
path.posix.basename('/tmp/myfile.html');
// returns 'myfile.html'
// Returns: 'myfile.html'
```
## path.basename(path[, ext])
@ -69,10 +69,10 @@ For example:
```js
path.basename('/foo/bar/baz/asdf/quux.html')
// returns 'quux.html'
// Returns: 'quux.html'
path.basename('/foo/bar/baz/asdf/quux.html', '.html')
// returns 'quux'
// Returns: 'quux'
```
A [`TypeError`][] is thrown if `path` is not a string or if `ext` is given
@ -92,20 +92,20 @@ For example, on POSIX:
```js
console.log(process.env.PATH)
// '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'
// Prints: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'
process.env.PATH.split(path.delimiter)
// returns ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']
// Returns: ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']
```
On Windows:
```js
console.log(process.env.PATH)
// 'C:\Windows\system32;C:\Windows;C:\Program Files\node\'
// 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\\']
// Returns: ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\']
```
## path.dirname(path)
@ -122,7 +122,7 @@ For example:
```js
path.dirname('/foo/bar/baz/asdf/quux')
// returns '/foo/bar/baz/asdf'
// Returns: '/foo/bar/baz/asdf'
```
A [`TypeError`][] is thrown if `path` is not a string.
@ -144,19 +144,19 @@ For example:
```js
path.extname('index.html')
// returns '.html'
// Returns: '.html'
path.extname('index.coffee.md')
// returns '.md'
// Returns: '.md'
path.extname('index.')
// returns '.'
// Returns: '.'
path.extname('index')
// returns ''
// Returns: ''
path.extname('.index')
// returns ''
// Returns: ''
```
A [`TypeError`][] is thrown if `path` is not a string.
@ -199,7 +199,7 @@ path.format({
dir: '/home/user/dir',
base: 'file.txt'
});
// returns '/home/user/dir/file.txt'
// Returns: '/home/user/dir/file.txt'
// `root` will be used if `dir` is not specified.
// If only `root` is provided or `dir` is equal to `root` then the
@ -208,7 +208,7 @@ path.format({
root: '/',
base: 'file.txt'
});
// returns '/file.txt'
// Returns: '/file.txt'
// `name` + `ext` will be used if `base` is not specified.
path.format({
@ -216,13 +216,13 @@ path.format({
name: 'file',
ext: '.txt'
});
// returns '/file.txt'
// Returns: '/file.txt'
// `base` will be returned if `dir` or `root` are not provided.
path.format({
base: 'file.txt'
});
// returns 'file.txt'
// Returns: 'file.txt'
```
On Windows:
@ -235,7 +235,7 @@ path.format({
ext : ".txt",
name : "file"
});
// returns 'C:\\path\\dir\\file.txt'
// Returns: 'C:\\path\\dir\\file.txt'
```
## path.isAbsolute(path)
@ -290,7 +290,7 @@ For example:
```js
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
// returns '/foo/bar/baz/asdf'
// Returns: '/foo/bar/baz/asdf'
path.join('foo', {}, 'bar')
// throws TypeError: Arguments to path.join must be strings
@ -319,14 +319,14 @@ For example on POSIX:
```js
path.normalize('/foo/bar//baz/asdf/quux/..')
// returns '/foo/bar/baz/asdf'
// Returns: '/foo/bar/baz/asdf'
```
On Windows:
```js
path.normalize('C:\\temp\\\\foo\\bar\\..\\');
// returns 'C:\\temp\\foo\\'
// Returns: 'C:\\temp\\foo\\'
```
A [`TypeError`][] is thrown if `path` is not a string.
@ -353,7 +353,7 @@ For example on POSIX:
```js
path.parse('/home/user/dir/file.txt')
// returns
// Returns:
// {
// root : "/",
// dir : "/home/user/dir",
@ -377,7 +377,7 @@ On Windows:
```js
path.parse('C:\\path\\dir\\file.txt')
// returns
// Returns:
// {
// root : "C:\\",
// dir : "C:\\path\\dir",
@ -426,14 +426,14 @@ For example on POSIX:
```js
path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
// returns '../../impl/bbb'
// Returns: '../../impl/bbb'
```
On Windows:
```js
path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb')
// returns '..\\..\\impl\\bbb'
// Returns: '..\\..\\impl\\bbb'
```
A [`TypeError`][] is thrown if neither `from` nor `to` is a string.
@ -468,10 +468,10 @@ For example:
```js
path.resolve('/foo/bar', './baz')
// returns '/foo/bar/baz'
// Returns: '/foo/bar/baz'
path.resolve('/foo/bar', '/tmp/file/')
// returns '/tmp/file'
// Returns: '/tmp/file'
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
// if the current working directory is /home/myself/node,
@ -494,14 +494,14 @@ For example on POSIX:
```js
'foo/bar/baz'.split(path.sep)
// returns ['foo', 'bar', 'baz']
// Returns: ['foo', 'bar', 'baz']
```
On Windows:
```js
'foo\\bar\\baz'.split(path.sep)
// returns ['foo', 'bar', 'baz']
// Returns: ['foo', 'bar', 'baz']
```
## path.win32