Skip to content

Commit d48ed95

Browse files
jasnellflakey5
authored andcommitted
src, lib: fixup lint and format issues for DataQueue/Blob
Co-authored-by: flakey5 <73616808+flakey5@users.noreply.github.com> PR-URL: #45258 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 36f36b9 commit d48ed95

18 files changed

Lines changed: 1251 additions & 1127 deletions

doc/api/fs.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,6 @@ When operating on file handles, the mode cannot be changed from what it was set
202202
to with [`fsPromises.open()`][]. Therefore, this is equivalent to
203203
[`filehandle.writeFile()`][].
204204

205-
#### `filehandle.blob()`
206-
<!-- YAML
207-
added: REPLACEME
208-
-->
209-
210-
> Stability: 1 - Experimental
211-
212-
Returns a {Blob} whose data is backed by this file.
213-
214205
#### `filehandle.chmod(mode)`
215206

216207
<!-- YAML
@@ -3333,6 +3324,45 @@ a colon, Node.js will open a file system stream, as described by
33333324
Functions based on `fs.open()` exhibit this behavior as well:
33343325
`fs.writeFile()`, `fs.readFile()`, etc.
33353326
3327+
### `fs.openAsBlob(path[, options])`
3328+
3329+
<!-- YAML
3330+
added: REPLACEME
3331+
-->
3332+
3333+
> Stability: 1 - Experimental
3334+
3335+
* `path` {string|Buffer|URL}
3336+
* `options` {Object}
3337+
* `type` {string} An optional mime type for the blob.
3338+
* Return: {Promise} containing {Blob}
3339+
3340+
Returns a {Blob} whose data is backed by the given file.
3341+
3342+
The file must not be modified after the {Blob} is created. Any modifications
3343+
will cause reading the {Blob} data to fail with a `DOMException`.
3344+
error. Synchronous stat operations on the file when the `Blob` is created, and
3345+
before each read in order to detect whether the file data has been modified
3346+
on disk.
3347+
3348+
```mjs
3349+
import { openAsBlob } from 'node:fs';
3350+
3351+
const blob = await openAsBlob('the.file.txt');
3352+
const ab = await blob.arrayBuffer();
3353