Rad*_*ith 10 javascript stream node.js
我的问题是我有一个流管道设置如下。
readableStream.pipe(transformStream).pipe(writableStream);
Run Code Online (Sandbox Code Playgroud)
我真的不想将可写流写入任何地方,我只是使用它,这样我的转换流的缓冲区就不会得到备份。如何使可写流写入空目的地?
有很多方法...其中一些会使节点崩溃并导致节点错误报告器崩溃...为了避免这种情况,不要在没有相应读取器的情况下使用 PassThrough,一定要调用回调。
// hellSpawn: 268MiB/s. RSS 298
// write2Null: 262MiB/s. RSS 138
// passThrough: 259MiB/s. RSS 2667
// noCb: 256MiB/s. RSS 2603
// fancy: 256MiB/s. RSS 106
{
hellSpawn: (childProcess.spawn('sh', ['-c', 'cat > /dev/null'])).stdin,
write2Null: fs.createWriteStream('/dev/null'),
passThrough: new PassThrough(),
noCb: new (class extends Writable {_write = () => {}})(),
fancy: new Writable ({write: (a,b,cb) => cb()})()
}
Run Code Online (Sandbox Code Playgroud)