From 76d10a10fb2f995aebb6df2470b02a9160bbeceb Mon Sep 17 00:00:00 2001 From: jaexxin Date: Tue, 30 Jul 2024 14:27:28 +0900 Subject: [PATCH] doc: add documentation for blob.bytes() method PR-URL: https://github.com/nodejs/node/pull/54114 Fixes: https://github.com/nodejs/node/issues/54105 Reviewed-By: Daeyeon Jeong Reviewed-By: Jake Yuesong Li --- doc/api/buffer.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index c72590cb71538c..6c587f58d7c4a4 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -513,6 +513,23 @@ added: Returns a promise that fulfills with an {ArrayBuffer} containing a copy of the `Blob` data. +#### `blob.bytes()` + + + +The `blob.bytes()` method returns the byte of the `Blob` object as a `Promise`. + +```js +const blob = new Blob(['hello']); +blob.bytes().then((bytes) => { + console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ] +}); +``` + ### `blob.size`