Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1652,8 +1652,10 @@ changes:
* `prefix` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {Promise} Fulfills with a string containing the file system path
of the newly created temporary directory.
* Returns: {Promise} Fulfills with the created directory path.
If `encoding` is `'buffer'`, then the resulting directory
path is returned as a {Buffer}. Otherwise, the path is returned as a
{string} using the specified encoding.

Creates a unique temporary directory. A unique directory name is generated by
appending six random characters to the end of the provided `prefix`. Due to
Expand Down Expand Up @@ -1692,14 +1694,15 @@ added: v24.4.0
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {Promise} Fulfills with a Promise for an async-disposable Object:
* `path` {string} The path of the created directory.
* `path` {string|Buffer} The path of the created directory.
* `remove` {AsyncFunction} A function which removes the created directory.
* `[Symbol.asyncDispose]` {AsyncFunction} The same as `remove`.

The resulting Promise holds an async-disposable object whose `path` property
holds the created directory path. When the object is disposed, the directory
and its contents will be removed asynchronously if it still exists. If the
directory cannot be deleted, disposal will throw an error. The object has an
holds the created directory path. If `encoding` is `'buffer'`, the `path` will
also be a {Buffer}, otherwise a {string}. When the object is disposed, the
directory and its contents will be removed asynchronously if it still exists. If
the directory cannot be deleted, disposal will throw an error. The object has an
async `remove()` method which will perform the same task.

Both this function and the disposal function on the resulting object are
Expand Down Expand Up @@ -4008,7 +4011,7 @@ changes:
* `encoding` {string} **Default:** `'utf8'`
* `callback` {Function}
* `err` {Error}
* `directory` {string}
* `directory` {string|Buffer}

Creates a unique temporary directory.

Expand All @@ -4018,12 +4021,14 @@ inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms,
notably the BSDs, can return more than six random characters, and replace
trailing `X` characters in `prefix` with random characters.

The created directory 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.

The created directory path is passed to the callback's second parameter. If
`encoding` is `'buffer'`, then the resulting directory path is passed as a
{Buffer}. Otherwise, the path is passed as a {string} using the specified
encoding.

```mjs
import { mkdtemp } from 'node:fs';
import { join } from 'node:path';
Expand Down Expand Up @@ -6500,9 +6505,11 @@ changes:
* `prefix` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {string}
* Returns: {string|Buffer}

Returns the created directory path.
Returns the created directory path. If `encoding` is `'buffer'`, then the
resulting directory path is returned as a {Buffer}. Otherwise, the path
is returned as a {string} using the specified encoding.

For detailed information, see the documentation of the asynchronous version of
this API: [`fs.mkdtemp()`][].
Expand All @@ -6520,15 +6527,15 @@ added: v24.4.0
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {Object} A disposable object:
* `path` {string} The path of the created directory.
* `path` {string|Buffer} The path of the created directory.
* `remove` {Function} A function which removes the created directory.
* `[Symbol.dispose]` {Function} The same as `remove`.

Returns a disposable object whose `path` property holds the created directory
path. When the object is disposed, the directory and its contents will be
removed if it still exists. If the directory cannot be deleted, disposal will
throw an error. The object has a `remove()` method which will perform the same
task.
path. If `encoding` is `'buffer'`, the `path` will be a {Buffer}. When the
object is disposed, the directory and its contents will be removed if it still
exists. If the directory cannot be deleted, disposal will throw an error. The
object has a `remove()` method which will perform the same task.

See the [MDN documentation on `using` statements][`using`] for more information about
explicit resource management.
Expand Down
Loading