async function offsetFileReader(file, offset, contentLength) {
  let totalRead = 0;
  let finished = false;
  await file.seek(offset, Deno.SeekMode.Start);
  async function read(buf) {
    if (finished) return null;
    let result;
    const remaining = contentLength - totalRead;
    if (remaining >= buf.byteLength) {
      result = await file.read(buf);
    } else {
      const readBuf = buf.subarray(0, remaining);
      result = await file.read(readBuf);
    }
    if (result !== null) {
      totalRead += result;
    }
    finished = totalRead === contentLength;
    return result;
  }
  return {
    read,
  };
}
/**
 * Sets the read offset of the provided file and returns a
 * Deno.Reader to read the file from the offset until the
 * provided contentLength;
 *
 * @param {Deno.File} file
 * @param {number} offset
 * @param {number} contentLength
 * @returns {Deno.Reader} reader
 * @private
 */
Sets the read offset of the provided file and returns a
Deno.Reader to read the file from the offset until the
provided contentLength.


Sets the read offset of the provided file and returns a Deno . Reader to read the file from the offset until the provided contentLength .
async function offsetFileReader(file, offset, contentLength) {
  let totalRead = 0;
  let finished = false;
  await file.seek(offset, Deno.SeekMode.Start);
  async function read(buf) {
    if (finished) return null;
    let result;
    const remaining = contentLength - totalRead;
    if (remaining >= buf.byteLength) {
      result = await file.read(buf);
    } else {
      const readBuf = buf.subarray(0, remaining);
      result = await file.read(readBuf);
    }
    if (result !== null) {
      totalRead += result;
    }
    finished = totalRead === contentLength;
    return result;
  }
  return {
    read,
  };
}
async function offsetFileReader ( file , offset , contentLength ) { let totalRead = 0 ; let finished = false ; await file . seek ( offset , Deno . SeekMode . Start ) ; async function read ( buf ) { if ( finished ) return null ; let result ; const remaining = contentLength - totalRead ; if ( remaining >= buf . byteLength ) { result = await file . read ( buf ) ; } else { const readBuf = buf . subarray ( 0 , remaining ) ; result = await file . read ( readBuf ) ; } if ( result !== null ) { totalRead += result ; } finished = totalRead === contentLength ; return result ; } return { read , } ; }
Sets the read offset of the provided file and returns a
 Deno.Reader to read the file from the offset until the
 provided contentLength;
Sets the read offset of the provided file and returns a Deno . Reader to read the file from the offset until the provided contentLength ;