async read(p) {
        let rr = p.byteLength;
        if (p.byteLength === 0) return rr;
        if (this.r === this.w) {
            if (p.byteLength >= this.buf.byteLength) {
                // Large read, empty buffer.
                // Read directly into p to avoid copy.
                const rr = await this.rd.read(p);
                const nread = rr ?? 0;
                assert(nread >= 0, "negative read");
                // if (rr.nread > 0) {
                //   this.lastByte = p[rr.nread - 1];
                //   this.lastCharSize = -1;
                // }
                return rr;
            }
            // One read.
            // Do not use this.fill, which will loop.
            this.r = 0;
            this.w = 0;
            rr = await this.rd.read(this.buf);
            if (rr === 0 || rr === null) return rr;
            assert(rr >= 0, "negative read");
            this.w += rr;
        }
        // copy as much as we can
        const copied = copyBytes(this.buf.subarray(this.r, this.w), p, 0);
        this.r += copied;
        // this.lastByte = this.buf[this.r - 1];
        // this.lastCharSize = -1;
        return copied;
    }
/** reads data into p.
   * It returns the number of bytes read into p.
   * The bytes are taken from at most one Read on the underlying Reader,
   * hence n may be less than len(p).
   * To read exactly len(p) bytes, use io.ReadFull(b, p).
   */
reads data into p.
It returns the number of bytes read into p.
The bytes are taken from at most one Read on the underlying Reader,
hence n may be less than len(p).
reads data into p . It returns the number of bytes read into p . The bytes are taken from at most one Read on the underlying Reader hence n may be less than len ( p ) .
async read(p) {
        let rr = p.byteLength;
        if (p.byteLength === 0) return rr;
        if (this.r === this.w) {
            if (p.byteLength >= this.buf.byteLength) {
                const rr = await this.rd.read(p);
                const nread = rr ?? 0;
                assert(nread >= 0, "negative read");
                return rr;
            }
            this.r = 0;
            this.w = 0;
            rr = await this.rd.read(this.buf);
            if (rr === 0 || rr === null) return rr;
            assert(rr >= 0, "negative read");
            this.w += rr;
        }
        const copied = copyBytes(this.buf.subarray(this.r, this.w), p, 0);
        this.r += copied;
        return copied;
    }
async read ( p ) { let rr = p . byteLength ; if ( p . byteLength === 0 ) return rr ; if ( this . r === this . w ) { if ( p . byteLength >= this . buf . byteLength ) { const rr = await this . rd . read ( p ) ; const nread = rr ?? 0 ; assert ( nread >= 0 , "negative read" ) ; return rr ; } this . r = 0 ; this . w = 0 ; rr = await this . rd . read ( this . buf ) ; if ( rr === 0 || rr === null ) return rr ; assert ( rr >= 0 , "negative read" ) ; this . w += rr ; } const copied = copyBytes ( this . buf . subarray ( this . r , this . w ) , p , 0 ) ; this . r += copied ; return copied ; }
reads data into p.
 It returns the number of bytes read into p.
 The bytes are taken from at most one Read on the underlying Reader,
 hence n may be less than len(p).
reads data into p . It returns the number of bytes read into p . The bytes are taken from at most one Read on the underlying Reader hence n may be less than len ( p ) .
// Large read, empty buffer. // Read directly into p to avoid copy. // if (rr.nread > 0) { //   this.lastByte = p[rr.nread - 1]; //   this.lastCharSize = -1; // } // One read. // Do not use this.fill, which will loop. // copy as much as we can // this.lastByte = this.buf[this.r - 1]; // this.lastCharSize = -1;