async readSlice(delim) {
        let s = 0; // search start index
        let slice;
        while(true){
            // Search buffer.
            let i = this.buf.subarray(this.r + s, this.w).indexOf(delim);
            if (i >= 0) {
                i += s;
                slice = this.buf.subarray(this.r, this.r + i + 1);
                this.r += i + 1;
                break;
            }
            // EOF?
            if (this.eof) {
                if (this.r === this.w) return null;
                slice = this.buf.subarray(this.r, this.w);
                this.r = this.w;
                break;
            }
            // Buffer full?
            if (this.buffered() >= this.buf.byteLength) {
                this.r = this.w;
                // #4521 The internal buffer should not be reused across reads because it causes corruption of data.
                const oldbuf = this.buf;
                const newbuf = this.buf.slice(0);
                this.buf = newbuf;
                throw new BufferFullError(oldbuf);
            }
            s = this.w - this.r; // do not rescan area we scanned before
            // Buffer is not full.
            try {
                await this._fill();
            } catch (err) {
                err.partial = slice;
                throw err;
            }
        }
        // Handle last byte, if any.
        // const i = slice.byteLength - 1;
        // if (i >= 0) {
        //   this.lastByte = slice[i];
        //   this.lastCharSize = -1
        // }
        return slice;
    }
/** `readSlice()` reads until the first occurrence of `delim` in the input,
   * returning a slice pointing at the bytes in the buffer. The bytes stop
   * being valid at the next read.
   *
   * If `readSlice()` encounters an error before finding a delimiter, or the
   * buffer fills without finding a delimiter, it throws an error with a
   * `partial` property that contains the entire buffer.
   *
   * If `readSlice()` encounters the end of the underlying stream and there are
   * any bytes left in the buffer, the rest of the buffer is returned. In other
   * words, EOF is always treated as a delimiter. Once the buffer is empty,
   * it returns `null`.
   *
   * Because the data returned from `readSlice()` will be overwritten by the
   * next I/O operation, most clients should use `readString()` instead.
   */
`readSlice()` reads until the first occurrence of `delim` in the input,
returning a slice pointing at the bytes in the buffer. The bytes stop
being valid at the next read.

If `readSlice()` encounters an error before finding a delimiter, or the
buffer fills without finding a delimiter, it throws an error with a
`partial` property that contains the entire buffer.

If `readSlice()` encounters the end of the underlying stream and there are
any bytes left in the buffer, the rest of the buffer is returned. In other
words, EOF is always treated as a delimiter. Once the buffer is empty,
it returns `null`.

Because the data returned from `readSlice()` will be overwritten by the
next I/O operation, most clients should use `readString()` instead.
` readSlice () ` reads until the first occurrence of ` delim ` in the input returning a slice pointing at the bytes in the buffer . The bytes stop being valid at the next read . If ` readSlice () ` encounters an error before finding a delimiter or the buffer fills without finding a delimiter it throws an error with a ` partial ` property that contains the entire buffer . If ` readSlice () ` encounters the end of the underlying stream and there are any bytes left in the buffer the rest of the buffer is returned . In other words EOF is always treated as a delimiter . Once the buffer is empty it returns ` null ` . Because the data returned from ` readSlice () ` will be overwritten by the next I / O operation most clients should use ` readString () ` instead .
async readSlice(delim) {
        let s = 0; 
        let slice;
        while(true){
            let i = this.buf.subarray(this.r + s, this.w).indexOf(delim);
            if (i >= 0) {
                i += s;
                slice = this.buf.subarray(this.r, this.r + i + 1);
                this.r += i + 1;
                break;
            }
            if (this.eof) {
                if (this.r === this.w) return null;
                slice = this.buf.subarray(this.r, this.w);
                this.r = this.w;
                break;
            }
            if (this.buffered() >= this.buf.byteLength) {
                this.r = this.w;
                const oldbuf = this.buf;
                const newbuf = this.buf.slice(0);
                this.buf = newbuf;
                throw new BufferFullError(oldbuf);
            }
            s = this.w - this.r; 
            try {
                await this._fill();
            } catch (err) {
                err.partial = slice;
                throw err;
            }
        }
        return slice;
    }
async readSlice ( delim ) { let s = 0 ; let slice ; while ( true ) { let i = this . buf . subarray ( this . r + s , this . w ) . indexOf ( delim ) ; if ( i >= 0 ) { i += s ; slice = this . buf . subarray ( this . r , this . r + i + 1 ) ; this . r += i + 1 ; break ; } if ( this . eof ) { if ( this . r === this . w ) return null ; slice = this . buf . subarray ( this . r , this . w ) ; this . r = this . w ; break ; } if ( this . buffered ( ) >= this . buf . byteLength ) { this . r = this . w ; const oldbuf = this . buf ; const newbuf = this . buf . slice ( 0 ) ; this . buf = newbuf ; throw new BufferFullError ( oldbuf ) ; } s = this . w - this . r ; try { await this . _fill ( ) ; } catch ( err ) { err . partial = slice ; throw err ; } } return slice ; }
`readSlice()` reads until the first occurrence of `delim` in the input,
 returning a slice pointing at the bytes in the buffer.
` readSlice () ` reads until the first occurrence of ` delim ` in the input returning a slice pointing at the bytes in the buffer .
// search start index // Search buffer. // EOF? // Buffer full? // #4521 The internal buffer should not be reused across reads because it causes corruption of data. // do not rescan area we scanned before // Buffer is not full. // Handle last byte, if any. // const i = slice.byteLength - 1; // if (i >= 0) { //   this.lastByte = slice[i]; //   this.lastCharSize = -1 // }