Permalink
Browse files

doc: include the optional options parameter

`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 jasnell committed Jul 22, 2016
1 parent 51f96df commit 6e50fc763700de31388580d701ebe4b3a507e673
Showing with 18 additions and 2 deletions.
  1. +18 −2 doc/api/fs.md
@@ -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
@@ -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
});
@@ -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

0 comments on commit 6e50fc7

Please sign in to comment.