From 03f5297ccd3c19f7be1a2ec9364015c1be3aaaae Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Sat, 23 Jul 2016 00:03:24 +0530 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/7842 Reviewed-By: James M Snell Reviewed-By: Claudio Rodriguez --- doc/api/fs.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index d3f42f89903c2d..d7297abfb0ce2c 100644 --- a/doc/api/fs.md +++ b/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) +* `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]) +* `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)