@@ -1652,8 +1652,10 @@ changes:
16521652* ` prefix` {string|Buffer|URL}
16531653* ` options` {string|Object}
16541654 * ` encoding` {string} **Default:** ` ' utf8' `
1655- * Returns: {Promise} Fulfills with a string containing the file system path
1656- of the newly created temporary directory.
1655+ * Returns: {Promise} Fulfills with the created directory path.
1656+ If ` encoding` is ` ' buffer' ` , then the resulting directory
1657+ path is returned as a {Buffer}. Otherwise, the path is returned as a
1658+ {string} using the specified encoding.
16571659
16581660Creates a unique temporary directory. A unique directory name is generated by
16591661appending six random characters to the end of the provided ` prefix` . Due to
@@ -1692,14 +1694,15 @@ added: v24.4.0
16921694* ` options` {string|Object}
16931695 * ` encoding` {string} **Default:** ` ' utf8' `
16941696* Returns: {Promise} Fulfills with a Promise for an async-disposable Object:
1695- * ` path` {string} The path of the created directory.
1697+ * ` path` {string|Buffer } The path of the created directory.
16961698 * ` remove` {AsyncFunction} A function which removes the created directory.
16971699 * ` [Symbol .asyncDispose ]` {AsyncFunction} The same as ` remove` .
16981700
16991701The resulting Promise holds an async-disposable object whose ` path` property
1700- holds the created directory path. When the object is disposed, the directory
1701- and its contents will be removed asynchronously if it still exists. If the
1702- directory cannot be deleted, disposal will throw an error. The object has an
1702+ holds the created directory path. If ` encoding` is ` ' buffer' ` , the ` path` will
1703+ also be a {Buffer}, otherwise a {string}. When the object is disposed, the
1704+ directory and its contents will be removed asynchronously if it still exists. If
1705+ the directory cannot be deleted, disposal will throw an error. The object has an
17031706async ` remove ()` method which will perform the same task.
17041707
17051708Both this function and the disposal function on the resulting object are
@@ -4008,7 +4011,7 @@ changes:
40084011 * `encoding` {string} **Default:** `'utf8'`
40094012* `callback` {Function}
40104013 * `err` {Error}
4011- * `directory` {string}
4014+ * `directory` {string|Buffer }
40124015
40134016Creates a unique temporary directory.
40144017
@@ -4018,12 +4021,14 @@ inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms,
40184021notably the BSDs, can return more than six random characters, and replace
40194022trailing `X` characters in `prefix` with random characters.
40204023
4021- The created directory path is passed as a string to the callback's second
4022- parameter.
4023-
40244024The optional `options` argument can be a string specifying an encoding, or an
40254025object with an `encoding` property specifying the character encoding to use.
40264026
4027+ The created directory path is passed to the callback's second parameter. If
4028+ `encoding` is `'buffer'`, then the resulting directory path is passed as a
4029+ {Buffer}. Otherwise, the path is passed as a {string} using the specified
4030+ encoding.
4031+
40274032```mjs
40284033import { mkdtemp } from 'node:fs';
40294034import { join } from 'node:path';
@@ -6500,9 +6505,11 @@ changes:
65006505* ` prefix` {string|Buffer|URL}
65016506* ` options` {string|Object}
65026507 * ` encoding` {string} **Default:** ` ' utf8' `
6503- * Returns: {string}
6508+ * Returns: {string|Buffer }
65046509
6505- Returns the created directory path.
6510+ Returns the created directory path. If ` encoding` is ` ' buffer' ` , then the
6511+ resulting directory path is returned as a {Buffer}. Otherwise, the path
6512+ is returned as a {string} using the specified encoding.
65066513
65076514For detailed information, see the documentation of the asynchronous version of
65086515this API: [` fs .mkdtemp ()` ][].
@@ -6520,15 +6527,15 @@ added: v24.4.0
65206527* ` options` {string|Object}
65216528 * ` encoding` {string} **Default:** ` ' utf8' `
65226529* Returns: {Object} A disposable object:
6523- * ` path` {string} The path of the created directory.
6530+ * ` path` {string|Buffer } The path of the created directory.
65246531 * ` remove` {Function} A function which removes the created directory.
65256532 * ` [Symbol .dispose ]` {Function} The same as ` remove` .
65266533
65276534Returns a disposable object whose ` path` property holds the created directory
6528- path. When the object is disposed , the directory and its contents will be
6529- removed if it still exists. If the directory cannot be deleted, disposal will
6530- throw an error. The object has a ` remove () ` method which will perform the same
6531- task.
6535+ path. If ` encoding ` is ` ' buffer ' ` , the ` path ` will be a {Buffer}. When the
6536+ object is disposed, the directory and its contents will be removed if it still
6537+ exists. If the directory cannot be deleted, disposal will throw an error. The
6538+ object has a ` remove () ` method which will perform the same task.
65326539
65336540See the [MDN documentation on ` using` statements][` using` ] for more information about
65346541explicit resource management.
0 commit comments