1

I am pretty new to JS and am having trouble getting the data from Stream.Writable.

The code I have looks something like this:

    const outputStream = new Stream.Writable();
    // Other things push data into the Writable stream here

    // Get the data from Writable stream here
    outputStream.destroy();

The Writable stream doesn't allow direct reading, so I am not really sure how to pull the data from it. Creating a Writable stream to a file and then reading from it seems unnecessarily overcomplicated.

I would like to write the output as a string to a variable.

Has anyone encountered the same task before, and if so, what can you suggest?
I would appreciate any help on this matter!

Abraham
  • 185
  • 1
  • 10
  • Does this answer your question? [How to implement a writable stream](https://stackoverflow.com/questions/21491567/how-to-implement-a-writable-stream) – Tyler Aldrich Nov 15 '22 at 15:33
  • You need to implement the `_write` method of the custom `Writable` you are creating, and that will be called when one of the "other things" pushes data to it. – Tyler Aldrich Nov 15 '22 at 15:34

0 Answers0