javascript - child.stdin 为什么不是 stream.Writable 的实例◔ ‸◔?
天蓬老师
天蓬老师 2017-04-17 16:37:37
0
0
428

问题:

官方文档中说child.stdin是一个可写流,child.stdin也确实可以使用stream.Writable类的方法,例如,child.stdin.write(),具体详见我的另一个问题(开始理解错误,以为 ChildProcess 本质是一个 process,所以使用的方法和属性跟使用 process 是一样的)。
child.stdin之所以可以使用write()方法,难道不是因为他是stream.Writable类的实例吗?但是通过代码测试却返回false

相关代码:

var stream = require('stream');
var spawn = require('child_process').spawn;
// 使用子进程 执行 tail 命令,实时查看被添加到 my_file 文件中的内容。
var child = spawn('tail', ['-f', '/var/temp/my_file']);
console.log(child.stdin instanceof stream.Writable); //=>false
console.log(child.stdin instanceof stream.Readable); //=>true
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

Antworte allen(0)
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage