You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a836720
Browse filesBrowse the repository at this point in the historyBrowse files
doc: add MDN links for explicit resource management in fs
Add cross-references to MDN documentation for `using` and `await using`
statements in the fs module documentation.
Remove TODO comment waiting for MDN documentation availability.
Fixes: #59556
PR-URL: #59557
Reviewed-By: René <[email protected]>
Copy file name to clipboardExpand all lines: doc/api/fs.md
+24-4Lines changed: 24 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1183,6 +1183,10 @@ changes:
1183
1183
Calls `filehandle.close()` and returns a promise that fulfills when the
1184
1184
filehandle is closed.
1185
1185
1186
+
This method enables the filehandle to be used with [`await using`][], which
1187
+
will automatically close the file when the scope exits. For more information,
1188
+
see the [MDN documentation on `using` statements][`using`].
1189
+
1186
1190
### `fsPromises.access(path[, mode])`
1187
1191
1188
1192
<!-- YAML
@@ -1665,10 +1669,11 @@ directory cannot be deleted, disposal will throw an error. The object has an
1665
1669
async `remove()` method which will perform the same task.
1666
1670
1667
1671
Both this function and the disposal function on the resulting object are
1668
-
async, so it should be used with `await` + `await using` as in
1672
+
async, so it should be used with `await` + [`await using`][] as in
1669
1673
`await using dir = await fsPromises.mkdtempDisposable('prefix')`.
1670
1674
1671
-
<!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
1675
+
See the [MDN documentation on `using` statements][`using`] for more information about
1676
+
explicit resource management.
1672
1677
1673
1678
For detailed information, see the documentation of [`fsPromises.mkdtemp()`][].
1674
1679
@@ -6417,12 +6422,13 @@ removed if it still exists. If the directory cannot be deleted, disposal will
6417
6422
throw an error. The object has a `remove()` method which will perform the same
6418
6423
task.
6419
6424
6420
-
<!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
6425
+
See the [MDN documentation on `using` statements][`using`] for more information about
6426
+
explicit resource management.
6421
6427
6422
6428
For detailed information, see the documentation of [`fs.mkdtemp()`][].
6423
6429
6424
6430
There is no callback-based version of this API because it is designed for use
6425
-
with the `using` syntax.
6431
+
with the [`using`][] syntax.
6426
6432
6427
6433
The optional `options` argument can be a string specifying an encoding, or an
6428
6434
object with an `encoding` property specifying the character encoding to use.
@@ -7294,6 +7300,10 @@ changes:
7294
7300
Calls `dir.close()` if the directory handle is open, and returns a promise that
7295
7301
fulfills when disposal is complete.
7296
7302
7303
+
This method enables the directory to be used with [`await using`][], which
7304
+
will automatically close the directory when the scope exits. For more
7305
+
information, see the [MDN documentation on `using` statements][`using`].
7306
+
7297
7307
#### `dir[Symbol.dispose]()`
7298
7308
7299
7309
<!-- YAML
@@ -7309,6 +7319,10 @@ changes:
7309
7319
Calls `dir.closeSync()` if the directory handle is open, and returns
7310
7320
`undefined`.
7311
7321
7322
+
This method enables the directory to be used with [`using`][], which
7323
+
will automatically close the directory when the scope exits. For more
7324
+
information, see the [MDN documentation on `using` statements][`using`].
7325
+
7312
7326
### Class: `fs.Dirent`
7313
7327
7314
7328
<!-- YAML
@@ -8443,6 +8457,10 @@ the `data` argument must be a {Buffer}.
8443
8457
8444
8458
Calls `utf8Stream.destroy()`.
8445
8459
8460
+
This method enables the stream to be used with [`using`][], which
8461
+
will automatically destroy the stream when the scope exits. For more
8462
+
information, see the [MDN documentation on `using` statements][`using`].
0 commit comments