customWS
それが書き込み可能なストリームであると仮定します..
util.inherits(customWS, stream.Writable);
_write()
以下のような書き込みを処理するロジックを実装します。
customWS.prototype._write = function(chunk, encoding, done) {
// ...
}
クラスを使用するには、customWS
以下のようにします..
aReadableStream.pipe(new customWS()).on('finish', callback);
関数のパラメータは何callback
ですか??
いいねを渡してもいいcallback
ですか..
function(data) {
// ...
}
..または修正されていますか??
修正されていない場合、そのようなコールバックをcustomWS
クラスに実装する方法は??
のようなものはありますか..
// in the implementation of customWS class
customWS.prototype._finish = function(user_specified_callback) {
user_specified_callback(some_data_say_a_bool_val);
}
// in the code, where i use the customWS class
aReadableStream.pipe(new customWS()).on('finish', function(flag) {
if (flag) {
console.log('yes');
}
});