Skip to content

Commit 6e50fc7

Browse files
thefourtheyejasnell
authored andcommitted
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 <[email protected]> Reviewed-By: Claudio Rodriguez <[email protected]>
1 parent 51f96df commit 6e50fc7

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

doc/api/fs.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,11 +893,16 @@ added: v0.1.21
893893

894894
Synchronous mkdir(2). Returns `undefined`.
895895

896-
## fs.mkdtemp(prefix, callback)
896+
## fs.mkdtemp(prefix[, options], callback)
897897
<!-- YAML
898898
added: v5.10.0
899899
-->
900900

901+
* `prefix` {String}
902+
* `options` {String | Object}
903+
* `encoding` {String} default = `'utf8'`
904+
* `callback` {Function}
905+
901906
Creates a unique temporary directory.
902907

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

914+
The optional `options` argument can be a string specifying an encoding, or an
915+
object with an `encoding` property specifying the character encoding to use.
916+
909917
Example:
910918

911919
```js
912920
fs.mkdtemp('/tmp/foo-', (err, folder) => {
921+
if (err) throw err;
913922
console.log(folder);
914923
// Prints: /tmp/foo-itXde2
915924
});
@@ -946,14 +955,21 @@ fs.mkdtemp(tmpDir + path.sep, (err, folder) => {
946955
});
947956
```
948957

949-
## fs.mkdtempSync(prefix)
958+
## fs.mkdtempSync(prefix[, options])
950959
<!-- YAML
951960
added: v5.10.0
952961
-->
953962

963+
* `prefix` {String}
964+
* `options` {String | Object}
965+
* `encoding` {String} default = `'utf8'`
966+
954967
The synchronous version of [`fs.mkdtemp()`][]. Returns the created
955968
folder path.
956969

970+
The optional `options` argument can be a string specifying an encoding, or an
971+
object with an `encoding` property specifying the character encoding to use.
972+
957973
## fs.open(path, flags[, mode], callback)
958974
<!-- YAML
959975
added: v0.0.2

0 commit comments

Comments
 (0)