Converting a Buffer into a ReadableStream in Node.js

后端 未结 8 1057
借酒劲吻你
借酒劲吻你 2020-11-27 16:09

I\'m fairly new to Buffers and ReadableStreams, so maybe this is a stupid question. I have a library that takes as input a ReadableStream, but my input is just

相关标签:
8条回答
  • 2020-11-27 16:37

    For nodejs 10.17.0 and up:

    const stream = Readable.from(myBuffer.toString());
    
    0 讨论(0)
  • 2020-11-27 16:37

    Here is a simple solution using streamifier module.

    const streamifier = require('streamifier');
    streamifier.createReadStream(new Buffer ([97, 98, 99])).pipe(process.stdout);
    

    You can use Strings, Buffer and Object as its arguments.

    0 讨论(0)
提交回复
热议问题