Categories
JavaScript Answers

How to convert a Buffer into a ReadableStream in Node.js?

Spread the love

To convert a Buffer into a ReadableStream in Node.js, we call the Readable.from method.

For instance, we write

const { Readable } = require("stream");

const stream = Readable.from(myBuffer);

to call Readable.from to convert the myBuffer to a readable stream.

This is avilable from Node.js 10.17.0 and up.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *