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 2de1d76
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
@@ -1661,10 +1665,11 @@ directory cannot be deleted, disposal will throw an error. The object has an
1661
1665
async `remove()` method which will perform the same task.
1662
1666
1663
1667
Both this function and the disposal function on the resulting object are
1664
-
async, so it should be used with `await` + `await using` as in
1668
+
async, so it should be used with `await` + [`await using`][] as in
1665
1669
`await using dir =awaitfsPromises.mkdtempDisposable('prefix')`.
1666
1670
1667
-
<!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
1671
+
See the [MDN documentation on `using` statements][`using`] for more information about
1672
+
explicit resource management.
1668
1673
1669
1674
For detailed information, see the documentation of [`fsPromises.mkdtemp()`][].
1670
1675
@@ -6393,12 +6398,13 @@ removed if it still exists. If the directory cannot be deleted, disposal will
6393
6398
throw an error. The object has a `remove()` method which will perform the same
6394
6399
task.
6395
6400
6396
-
<!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
6401
+
See the [MDN documentation on `using` statements][`using`] for more information about
6402
+
explicit resource management.
6397
6403
6398
6404
For detailed information, see the documentation of [`fs.mkdtemp()`][].
6399
6405
6400
6406
There is no callback-based version of this API because it is designed for use
6401
-
with the `using` syntax.
6407
+
with the [`using`][] syntax.
6402
6408
6403
6409
The optional `options` argument can be a string specifying an encoding, or an
6404
6410
object with an `encoding` property specifying the character encoding to use.
@@ -7273,6 +7279,10 @@ changes:
7273
7279
Calls `dir.close()` if the directory handle is open, and returns a promise that
7274
7280
fulfills when disposal is complete.
7275
7281
7282
+
This method enables the directory to be used with [`await using`][], which
7283
+
will automatically close the directory when the scope exits. For more
7284
+
information, see the [MDN documentation on `using` statements][`using`].
7285
+
7276
7286
#### `dir[Symbol.dispose]()`
7277
7287
7278
7288
<!-- YAML
@@ -7286,6 +7296,10 @@ changes:
7286
7296
Calls `dir.closeSync()` if the directory handle is open, and returns
7287
7297
`undefined`.
7288
7298
7299
+
This method enables the directory to be used with [`using`][], which
7300
+
will automatically close the directory when the scope exits. For more
7301
+
information, see the [MDN documentation on `using` statements][`using`].
7302
+
7289
7303
### Class: `fs.Dirent`
7290
7304
7291
7305
<!-- YAML
@@ -8397,6 +8411,10 @@ the `data` argument must be a {Buffer}.
8397
8411
8398
8412
Calls `utf8Stream.destroy()`.
8399
8413
8414
+
This method enables the stream to be used with [`using`][], which
8415
+
will automatically destroy the stream when the scope exits. For more
8416
+
information, see the [MDN documentation on `using` statements][`using`].
0 commit comments