From 228067ba4bd118130cf6b036ed8d3af464e9dab9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 6 Sep 2021 20:07:59 +0200 Subject: [PATCH 1/2] fs: add `FileHandle.prototype.arrayBuffer` method Refs: https://w3c.github.io/FileAPI/#dom-blob-arraybuffer --- doc/api/fs.md | 11 +++++++ lib/internal/fs/promises.js | 5 ++++ ...est-fs-promises-file-handle-arrayBuffer.js | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 test/parallel/test-fs-promises-file-handle-arrayBuffer.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 3be576e175eed5..319c9d840e7001 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -188,6 +188,17 @@ 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.arrayBuffer()` + + +> Stability: 1 - Experimental + +* Returns: {Promise} Fulfills with an {ArrayBuffer} upon success. + +Reads the whole file as binary data. + #### `filehandle.chmod(mode)` + +> Stability: 1 - Experimental + +* Returns: {Promise} Fulfills with a {string} upon success. + +Reads the whole file as UTF-8 text. + #### `filehandle.truncate(len)`