Skip to content

Commit

Permalink
doc: include the optional options parameter
Browse files Browse the repository at this point in the history
`mkdtemp` functions accept an optional `options` parameter, which can
be either a String specifying encoding, or an Object with an `encoding`
property.

PR-URL: #7842
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
  • Loading branch information
thefourtheye authored and Fishrock123 committed Sep 9, 2016
1 parent 6ae7af0 commit 03f5297
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -893,11 +893,16 @@ added: v0.1.21

Synchronous mkdir(2). Returns `undefined`.

## fs.mkdtemp(prefix, callback)
## fs.mkdtemp(prefix[, options], callback)
<!-- YAML
added: v5.10.0
-->

* `prefix` {String}
* `options` {String | Object}
* `encoding` {String} default = `'utf8'`
* `callback` {Function}

Creates a unique temporary directory.

Generates six random characters to be appended behind a required
Expand All @@ -906,10 +911,14 @@ Generates six random characters to be appended behind a required
The created folder path is passed as a string to the callback's second
parameter.

The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use.

Example:

```js
fs.mkdtemp('/tmp/foo-', (err, folder) => {
if (err) throw err;
console.log(folder);
// Prints: /tmp/foo-itXde2
});
Expand Down Expand Up @@ -946,14 +955,21 @@ fs.mkdtemp(tmpDir + path.sep, (err, folder) => {
});
```

## fs.mkdtempSync(prefix)
## fs.mkdtempSync(prefix[, options])
<!-- YAML
added: v5.10.0
-->

* `prefix` {String}
* `options` {String | Object}
* `encoding` {String} default = `'utf8'`

The synchronous version of [`fs.mkdtemp()`][]. Returns the created
folder path.

The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use.

## fs.open(path, flags[, mode], callback)
<!-- YAML
added: v0.0.2
Expand Down

0 comments on commit 03f5297

Please sign in to comment.