Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a97dfa0

Browse filesBrowse files
committed
doc: explain path.format() algorithm
PR-URL: #5688 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com> Reviewed-By: James M Snell <jasnell@gmail.com> Fixes: #2305
1 parent e7039db commit a97dfa0
Copy full SHA for a97dfa0

File tree

Expand file treeCollapse file tree

1 file changed

+16
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/path.markdown‎

Copy file name to clipboardExpand all lines: doc/api/path.markdown
+16-1Lines changed: 16 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,22 @@ path.extname('.index')
9393

9494
## path.format(pathObject)
9595

96-
Returns a path string from an object, the opposite of [`path.parse`][].
96+
Returns a path string from an object. This is the opposite of [`path.parse`][].
97+
98+
If `pathObject` has all expected properties, the returned string will be a
99+
concatenation of the `dir` property, the platform-dependent path separator, and
100+
the `base` property.
101+
102+
If the `dir` property is not supplied, the `root` property will be used as the
103+
`dir` property. However, it will be assumed that the `root` property already
104+
ends with the platform-dependent path separator. In this case, the returned
105+
string will be the concatenation fo the `root` property and the `base` property.
106+
107+
If both the `dir` and the `root` properties are not supplied, then the returned
108+
string will be the contents of the `base` property.
109+
110+
If the `base` property is not supplied, a concatenation of the `name` property
111+
and the `ext` property will be used as the `base` property.
97112

98113
```js
99114
path.format({

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.