exec.start(function(err, stream) { if (err) return; stream.setEncoding('utf8'); stream.pipe(process.stdout); // how to get the output result?? // return result; });
如上,如何获取stream流的信息,并返回。thanks.
回复 (3)
B
用 Writable Stream
exec.start(function(err, stream) {
if (err) return;
stream.setEncoding(‘utf8’);
var Writable = require('stream').Writable;
var ws = Writable();
ws._write = function (chunk, encoding, next) {
// chunk 就是你要的
next();
}
stream.pipe(ws);
});
I
引用 booxood用 Writable Stream
@booxood stream是有on回调的
J
多谢各位
参与回复
登录后即可参与回复。登录