From 71fb06fd64c873e2c716e23ca1d31219cf78cbd6 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sat, 17 Dec 2022 13:58:26 -0800 Subject: [PATCH] src, lib: fixup lint and format issues for DataQueue/Blob Co-authored-by: flakey5 <73616808+flakey5@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/45258 Reviewed-By: Matteo Collina --- doc/api/fs.md | 48 +- lib/fs.js | 19 + lib/internal/blob.js | 48 +- lib/internal/fs/promises.js | 10 - src/async_wrap.h | 86 +- src/dataqueue/queue.cc | 1119 ++++++++--------- src/dataqueue/queue.h | 75 +- src/env_properties.h | 1 - src/node_blob.cc | 157 ++- src/node_blob.h | 34 +- src/node_bob-inl.h | 3 +- src/node_bob.h | 11 +- src/node_file.cc | 34 +- src/node_file.h | 7 +- test/cctest/test_dataqueue.cc | 518 +++++--- test/parallel/test-blob-file-backed.js | 68 +- test/parallel/test-bootstrap-modules.js | 126 +- test/parallel/test-trace-events-threadpool.js | 14 +- 18 files changed, 1251 insertions(+), 1127 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index b1fac10e45c6c0..5fd4cfeefb504d 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -202,15 +202,6 @@ When operating on file handles, the mode cannot be changed from what it was set to with [`fsPromises.open()`][]. Therefore, this is equivalent to [`filehandle.writeFile()`][]. -#### `filehandle.blob()` - - -> Stability: 1 - Experimental - -Returns a {Blob} whose data is backed by this file. - #### `filehandle.chmod(mode)` + +> Stability: 1 - Experimental + +* `path` {string|Buffer|URL} +* `options` {Object} + * `type` {string} An optional mime type for the blob. +* Return: {Promise} containing {Blob} + +Returns a {Blob} whose data is backed by the given file. + +The file must not be modified after the {Blob} is created. Any modifications +will cause reading the {Blob} data to fail with a `DOMException`. +error. Synchronous stat operations on the file when the `Blob` is created, and +before each read in order to detect whether the file data has been modified +on disk. + +```mjs +import { openAsBlob } from 'node:fs'; + +const blob = await openAsBlob('the.file.txt'); +const ab = await blob.arrayBuffer(); +blob.stream(); +``` + +```cjs +const { openAsBlob } = require('node:fs'); + +(async () => { + const blob = await openAsBlob('the.file.txt'); + const ab = await blob.arrayBuffer(); + blob.stream(); +})(); +``` + ### `fs.opendir(path[, options], callback)`