import { EventEmitter } from 'events' ; import type * as stream from 'stream' ; import type { BufferEncoding , Callback } from '../../_internal/types' ; export class Writable extends EventEmitter implements stream . Writable { readonly writable : boolean = true ; writableEnded : boolean = false ; writableFinished : boolean = false ; readonly writableHighWaterMark : number = 0 ; readonly writableLength : number = 0 ; readonly writableObjectMode : boolean = false ; readonly writableCorked : number = 0 ; destroyed : boolean = false ; _data : unknown ; _encoding : BufferEncoding = 'utf-8' ; constructor ( _opts ? ) { super ( ) ; } pipe < T > ( _destenition , _options ? ) { return { } as T ; } _write ( chunk , encoding , callback ? ) { this . _data = chunk ; this . _encoding = encoding ; if ( callback ) { callback ( ) ; } } _writev ? ( _chunks , _callback ) { } _destroy ( _error , _callback ) { } _final ( _callback ) { } write ( chunk , arg2 ? , arg3 ? ) { const encoding = typeof arg2 === 'string' ? this . _encoding : 'utf-8' ; const cb = typeof arg2 === 'function' ? arg2 : ( typeof arg3 === 'function' ? arg3 : undefined ) ; this . _write ( chunk , encoding , cb ) ; return true ; } setDefaultEncoding ( _encoding ) { return this ; } end ( arg1 , arg2 ? , arg3 ? ) { const cb = ( typeof arg1 === 'function' ) ? arg1 : ( typeof arg2 === 'function' ? arg2 : ( typeof arg3 === 'function' ? arg3 : undefined ) ) ; const data = arg1 !== cb ? arg1 : undefined ; if ( data ) { const encoding = arg2 !== cb ? arg2 : undefined ; this . write ( data , encoding , cb ) ; } this . writableEnded = true ; this . writableFinished = true ; this . emit ( 'close' ) ; this . emit ( 'finish' ) ; return this as unknown as void ; } cork ( ) { } uncork ( ) { } destroy ( _error ? ) { this . destroyed = true ; delete this . _data ; this . removeAllListeners ( ) ; return this as unknown as void ; } }