The super constructor to "inherits" must not be null or undefined
这种错误怎么回事?inherits还要安装模块吗?
//自我定制的各种流
var stream=require('stream');
var util=require('util');
function ReadStream(){
stream.ReadStream.call(this)
}
util.inherits(ReadStream,stream.Readable)
ReadStream.prototype._read=function(){
this.push('I ');
this.push('Iove ');
this.push('Imooc ');
this.push(null);
}
// 声明可读流完成,可读流负责push数据
//
// 可写流的声明
function WritStream(){
stream.wirtable.call(this);
// 缓存
this._cashed=new Buffer('')
}
util.inherits(WritStream,stream.Wirtable);
// 重写可写流的write方法
WritStream.prototype._write=function(chunk,encode,cb){
console.log(chunk.toString())
cb()
}
function TransformStream() {
stream.Transform.call(this)
}
util.inherits(TransformStream,stream.transform);
TransformStream.prototype._transform=function(chunk,encode, cb){
this.push(chunk)
cb()
}
TransformStream.prototype._flush=function(cb){
this.push('Oh Year ');
cb()
}
var rs=new ReadStream()
var ws=new WritStream()
var ts=new TransformStream()
rs.pipe(ts).pipe(ws)