From f8f902c1f21c0aff158638e73778344c6fed1888 Mon Sep 17 00:00:00 2001 From: greenhead Date: Sat, 29 Aug 2026 19:50:33 +0900 Subject: [PATCH] fs: add openAsBlobSync Signed-off-by: greenhead Assisted-by: Codex --- doc/api/fs.md | 15 +++++ lib/fs.js | 24 ++++++++ .../bootstrap/switches/is_main_thread.js | 6 +- lib/internal/vfs/setup.js | 2 + test/fixtures/permission/fs-read.js | 27 ++++++++- test/parallel/test-fs-openAsBlobSync.js | 58 +++++++++++++++++++ test/parallel/test-permission-fs-supported.js | 2 +- test/parallel/test-vfs-fs-openAsBlob.js | 42 ++++++++++++-- 8 files changed, 165 insertions(+), 11 deletions(-) create mode 100644 test/parallel/test-fs-openAsBlobSync.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 9b35dcb3b458..66d996c46201 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -6541,6 +6541,20 @@ with the [`using`][] syntax. The optional `options` argument can be a string specifying an encoding, or an object with an `encoding` property specifying the character encoding to use. +### `fs.openAsBlobSync(path[, options])` + + + +* `path` {string|Buffer|URL} +* `options` {Object} + * `type` {string} An optional mime type for the blob. +* Returns: {Blob} + +For detailed information, see the documentation of the Promise-returning +version of this API: [`fs.openAsBlob()`][]. + ### `fs.opendirSync(path[, options])`