async function copyN(r, dest, size) {
  let bytesRead = 0;
  let buf = new Uint8Array(DEFAULT_BUFFER_SIZE);
  while (bytesRead < size) {
    if (size - bytesRead < DEFAULT_BUFFER_SIZE) {
      buf = new Uint8Array(size - bytesRead);
    }
    const result = await r.read(buf);
    const nread = result ?? 0;
    bytesRead += nread;
    if (nread > 0) {
      let n = 0;
      while (n < nread) {
        n += await dest.write(buf.slice(n, nread));
      }
      assert(n === nread, "could not write");
    }
    if (result === null) {
      break;
    }
  }
  return bytesRead;
}
/** copy N size at the most.
 *  If read size is lesser than N, then returns nread
 * */
copy N size at the most.
If read size is lesser than N, then returns nread
copy N size at the most . If read size is lesser than N then returns nread
async function copyN(r, dest, size) {
  let bytesRead = 0;
  let buf = new Uint8Array(DEFAULT_BUFFER_SIZE);
  while (bytesRead < size) {
    if (size - bytesRead < DEFAULT_BUFFER_SIZE) {
      buf = new Uint8Array(size - bytesRead);
    }
    const result = await r.read(buf);
    const nread = result ?? 0;
    bytesRead += nread;
    if (nread > 0) {
      let n = 0;
      while (n < nread) {
        n += await dest.write(buf.slice(n, nread));
      }
      assert(n === nread, "could not write");
    }
    if (result === null) {
      break;
    }
  }
  return bytesRead;
}
async function copyN ( r , dest , size ) { let bytesRead = 0 ; let buf = new Uint8Array ( DEFAULT_BUFFER_SIZE ) ; while ( bytesRead < size ) { if ( size - bytesRead < DEFAULT_BUFFER_SIZE ) { buf = new Uint8Array ( size - bytesRead ) ; } const result = await r . read ( buf ) ; const nread = result ?? 0 ; bytesRead += nread ; if ( nread > 0 ) { let n = 0 ; while ( n < nread ) { n += await dest . write ( buf . slice ( n , nread ) ) ; } assert ( n === nread , "could not write" ) ; } if ( result === null ) { break ; } } return bytesRead ; }
copy N size at the most.
copy N size at the most .