From 091a579275d8a967acf90695883f525360364a58 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 6 Aug 2021 16:54:13 -0700 Subject: [PATCH] buffer: add Blob.prototype.stream method and other cleanups Adds the `stream()` method to get a `ReadableStream` for the `Blob`. Also makes some other improvements to get the implementation closer to the API standard definition. Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/39693 Reviewed-By: Anna Henningsen Reviewed-By: Benjamin Gruenbaum Reviewed-By: Bradley Farias Reviewed-By: Stephen Belanger --- doc/api/buffer.md | 13 +++- lib/internal/blob.js | 145 +++++++++++++++++++++++++++++-------- test/parallel/test-blob.js | 18 +++++ 3 files changed, 145 insertions(+), 31 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index a8a7635dbdc748..bd7122d5b4d47a 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -507,6 +507,15 @@ added: v15.7.0 Creates and returns a new `Blob` containing a subset of this `Blob` objects data. The original `Blob` is not altered. +### `blob.stream()` + + +* Returns: {ReadableStream} + +Returns a new `ReadableStream` that allows the content of the `Blob` to be read. + ### `blob.text()`