From 8a253973765606fc9835ff871372d1ecf2b02695 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Thu, 22 Jun 2023 12:04:01 +0300 Subject: [PATCH 01/10] fs, stream: initial `Symbol.dispose` and `Symbol.asyncDispose` support Co-authored-by: Benjamin Gruenbaum --- doc/api/fs.md | 8 +++++++ doc/api/stream.md | 8 +++++++ lib/internal/fs/promises.js | 5 ++++ lib/internal/per_context/primordials.js | 5 ++++ lib/internal/process/pre_execution.js | 11 +++++++++ lib/internal/streams/readable.js | 8 +++++++ .../test-fs-promises-file-handle-dispose.js | 12 ++++++++++ test/parallel/test-stream-readable-dispose.js | 23 +++++++++++++++++++ typings/primordials.d.ts | 2 ++ 9 files changed, 82 insertions(+) create mode 100644 test/parallel/test-fs-promises-file-handle-dispose.js create mode 100644 test/parallel/test-stream-readable-dispose.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 01abd668c499b0..5ddc2a5b2d0977 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -817,6 +817,14 @@ On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file. +#### `filehandle[Symbol.asyncDispose]()` + + + +An alias for `filehandle.close()`. + ### `fsPromises.access(path[, mode])` + +An alias for [`readable.destroy()`][readable-destroy] with an `AbortError`. + ##### `readable.compose(stream[, options])` +> Stability: 1 - Experimental + An alias for `filehandle.close()`. ### `fsPromises.access(path[, mode])` diff --git a/doc/api/stream.md b/doc/api/stream.md index 22d0178389ffe0..c8a7544fa2b1d3 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1910,6 +1910,8 @@ has less then 64 KiB of data because no `highWaterMark` option is provided to added: REPLACEME --> +> Stability: 1 - Experimental + An alias for [`readable.destroy()`][readable-destroy] with an `AbortError`. ##### `readable.compose(stream[, options])` From 5d0d435eb6fa6655b0519c5effa214e5e1706834 Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Fri, 23 Jun 2023 14:05:00 +0300 Subject: [PATCH 10/10] Update doc/api/stream.md --- doc/api/stream.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index c8a7544fa2b1d3..72ccfe50aeee18 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1912,7 +1912,8 @@ added: REPLACEME > Stability: 1 - Experimental -An alias for [`readable.destroy()`][readable-destroy] with an `AbortError`. +Calls [`readable.destroy()`][readable-destroy] with an `AbortError` and returns +a promise that fulfills when the stream is finished. ##### `readable.compose(stream[, options])`