async readFromStream(buffer, offset, length) {
        const readBuffer = this.s.read(length);
        if (readBuffer) {
            buffer.set(readBuffer, offset);
            return readBuffer.length;
        }
        else {
            const request = {
                buffer,
                offset,
                length,
                deferred: new Deferred_1.Deferred()
            };
            this.deferred = request.deferred;
            this.s.once('readable', () => {
                this.readDeferred(request);
            });
            return request.deferred.promise;
        }
    }
/**
     * Read chunk from stream
     * @param buffer Target Uint8Array (or Buffer) to store data read from stream in
     * @param offset Offset target
     * @param length Number of bytes to read
     * @returns Number of bytes read
     */
Read chunk from stream
@param buffer Target Uint8Array (or Buffer) to store data read from stream in
@param offset Offset target
@param length Number of bytes to read
@returns Number of bytes read
Read chunk from stream @param buffer Target Uint8Array ( or Buffer ) to store data read from stream in @param offset Offset target @param length Number of bytes to read @returns Number of bytes read
async readFromStream(buffer, offset, length) {
        const readBuffer = this.s.read(length);
        if (readBuffer) {
            buffer.set(readBuffer, offset);
            return readBuffer.length;
        }
        else {
            const request = {
                buffer,
                offset,
                length,
                deferred: new Deferred_1.Deferred()
            };
            this.deferred = request.deferred;
            this.s.once('readable', () => {
                this.readDeferred(request);
            });
            return request.deferred.promise;
        }
    }
async readFromStream ( buffer , offset , length ) { const readBuffer = this . s . read ( length ) ; if ( readBuffer ) { buffer . set ( readBuffer , offset ) ; return readBuffer . length ; } else { const request = { buffer , offset , length , deferred : new Deferred_1 . Deferred ( ) } ; this . deferred = request . deferred ; this . s . once ( 'readable' , ( ) => { this . readDeferred ( request ) ; } ) ; return request . deferred . promise ; } }
Read chunk from stream
 @param buffer Target Uint8Array (or Buffer) to store data read from stream in
 @param offset Offset target
 @param length Number of bytes to read
 @returns Number of bytes read
Read chunk from stream @param buffer Target Uint8Array ( or Buffer ) to store data read from stream in @param offset Offset target @param length Number of bytes to read @returns Number of bytes read