async function readAllBytes (reader, successSteps, failureSteps) {
  const bytes = []
  let byteLength = 0

  try {
    do {
      const { done, value: chunk } = await reader.read()

      if (done) {
        // 1. Call successSteps with bytes.
        successSteps(Buffer.concat(bytes, byteLength))
        return
      }

      // 1. If chunk is not a Uint8Array object, call failureSteps
      //    with a TypeError and abort these steps.
      if (!isUint8Array(chunk)) {
        failureSteps(TypeError('Received non-Uint8Array chunk'))
        return
      }

      // 2. Append the bytes represented by chunk to bytes.
      bytes.push(chunk)
      byteLength += chunk.length

    // 3. Read-loop given reader, bytes, successSteps, and failureSteps.
    } while (true)
  } catch (e) {
    // 1. Call failureSteps with e.
    failureSteps(e)
  }
}
@see https://streams.spec.whatwg.org/#readablestreamdefaultreader-read-all-bytes
@see https://streams.spec.whatwg.org/#read-loop
@param {ReadableStreamDefaultReader} reader
@param {(bytes: Uint8Array) => void} successSteps
@param {(error: Error) => void} failureSteps