import { Writable , WritableOptions } from 'stream' ; export class MockWritable extends Writable { private _data : any [ ] = [ ] ; constructor ( options ? ) { super ( options ) ; } public end ( ) { this . emit ( 'end' ) ; super . end ( ) ; } public write ( data ) { this . _data . push ( data ) ; return super . write ( data ) ; } public data ( ) { return this . _data . slice ( 0 ) ; } public _write ( data , encoding , callback ) { this . emit ( 'data' , Buffer . isBuffer ( data ) ? data . toString ( 'utf8' || encoding ) : data ) ; callback ( ) ; } }