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 714dc5d
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
@@ -1188,6 +1188,10 @@ changes:
1188
1188
Calls `filehandle.close()` and returns a promise that fulfills when the
1189
1189
filehandle is closed.
1190
1190
1191
+
This method enables the filehandle to be used with [`await using`][], which
1192
+
will automatically close the file when the scope exits. For more information,
1193
+
see the [MDN documentation on `using` statements][`using`].
1194
+
1191
1195
### `fsPromises.access(path[, mode])`
1192
1196
1193
1197
<!-- YAML
@@ -1672,10 +1676,11 @@ directory cannot be deleted, disposal will throw an error. The object has an
1672
1676
async `remove()` method which will perform the same task.
1673
1677
1674
1678
Both this function and the disposal function on the resulting object are
1675
-
async, so it should be used with `await` + `await using` as in
1679
+
async, so it should be used with `await` + [`await using`][] as in
1676
1680
`await using dir =awaitfsPromises.mkdtempDisposable('prefix')`.
1677
1681
1678
-
<!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
1682
+
See the [MDN documentation on `using` statements][`using`] for more information about
1683
+
explicit resource management.
1679
1684
1680
1685
For detailed information, see the documentation of [`fsPromises.mkdtemp()`][].
1681
1686
@@ -6430,12 +6435,13 @@ removed if it still exists. If the directory cannot be deleted, disposal will
6430
6435
throw an error. The object has a `remove()` method which will perform the same
6431
6436
task.
6432
6437
6433
-
<!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
6438
+
See the [MDN documentation on `using` statements][`using`] for more information about
6439
+
explicit resource management.
6434
6440
6435
6441
For detailed information, see the documentation of [`fs.mkdtemp()`][].
6436
6442
6437
6443
There is no callback-based version of this API because it is designed for use
6438
-
with the `using` syntax.
6444
+
with the [`using`][] syntax.
6439
6445
6440
6446
The optional `options` argument can be a string specifying an encoding, or an
6441
6447
object with an `encoding` property specifying the character encoding to use.
@@ -7307,6 +7313,10 @@ changes:
7307
7313
Calls `dir.close()` if the directory handle is open, and returns a promise that
7308
7314
fulfills when disposal is complete.
7309
7315
7316
+
This method enables the directory to be used with [`await using`][], which
7317
+
will automatically close the directory when the scope exits. For more
7318
+
information, see the [MDN documentation on `using` statements][`using`].
7319
+
7310
7320
#### `dir[Symbol.dispose]()`
7311
7321
7312
7322
<!-- YAML
@@ -7322,6 +7332,10 @@ changes:
7322
7332
Calls `dir.closeSync()` if the directory handle is open, and returns
7323
7333
`undefined`.
7324
7334
7335
+
This method enables the directory to be used with [`using`][], which
7336
+
will automatically close the directory when the scope exits. For more
7337
+
information, see the [MDN documentation on `using` statements][`using`].
7338
+
7325
7339
### Class: `fs.Dirent`
7326
7340
7327
7341
<!-- YAML
@@ -8458,6 +8472,10 @@ the `data` argument must be a {Buffer}.
8458
8472
8459
8473
Calls `utf8Stream.destroy()`.
8460
8474
8475
+
This method enables the stream to be used with [`using`][], which
8476
+
will automatically destroy the stream when the scope exits. For more
8477
+
information, see the [MDN documentation on `using` statements][`using`].
0 commit comments