var EventEmitter=require("events").EventEmitter,Writable=require("stream").Writable,util=require("util");function FlushWritable(t){Writable.call(this,t)}util.inherits(FlushWritable,Writable),FlushWritable.prototype.emit=function(t){if("finish"===t&&this._flush&&!Writable.prototype._flush)this._flush(function(t){t?EventEmitter.prototype.emit.call(this,"error",t):EventEmitter.prototype.emit.call(this,"finish")}.bind(this));else{var e=Array.prototype.slice.call(arguments);EventEmitter.prototype.emit.apply(this,e)}},module.exports=FlushWritable;