How to emit/pipe array values as a readable stream in node.js?

前端 未结 5 2226
梦谈多话
梦谈多话 2021-02-07 09:23

What is the best way to create a readable stream from an array and pipe values to a writable stream? I have seen substack\'s example using setInterval and I can implement that s

5条回答
  •  忘了有多久
    2021-02-07 10:09

    As of Node 12.3, you can use stream.Readable.from(iterable, [options]) instead.

    const { Readable } = require('stream');
    const readableStream = Readable.from(arr);
    

提交回复
热议问题