Skip to content

Commit

Permalink
doc: explain path.format() algorithm
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Trott authored and Myles Borins committed Mar 17, 2016
1 parent 8081e95 commit 49fd6ad
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion doc/api/path.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,22 @@ path.extname('.index')

## path.format(pathObject)

Returns a path string from an object, the opposite of [`path.parse`][].
Returns a path string from an object. This is the opposite of [`path.parse`][].

If `pathObject` has all expected properties, the returned string will be a
concatenation of the `dir` property, the platform-dependent path separator, and
the `base` property.

If the `dir` property is not supplied, the `root` property will be used as the
`dir` property. However, it will be assumed that the `root` property already
ends with the platform-dependent path separator. In this case, the returned
string will be the concatenation fo the `root` property and the `base` property.

If both the `dir` and the `root` properties are not supplied, then the returned
string will be the contents of the `base` property.

If the `base` property is not supplied, a concatenation of the `name` property
and the `ext` property will be used as the `base` property.

```js
path.format({
Expand Down

0 comments on commit 49fd6ad

Please sign in to comment.