lib/reader.js
function Reader(input) {
  this.stream = input;
  if (input[externalBuffer]) {
    this[externalBuffer] = input[externalBuffer].slice();
  }
  let streamType = streams.isStream(input);
  if (streamType === 'node') {
    input = streams.nodeToWeb(input);
  }
  if (streamType) {
    const reader = input.getReader();
    this._read = reader.read.bind(reader);
    this._releaseLock = () => {
      reader.closed.catch(function() {});
      reader.releaseLock();
    };
    return;
  }
  let doneReading = false;
  this._read = async () => {
    if (doneReading || doneReadingSet.has(input)) {
      return { value: undefined, done: true };
    }
    doneReading = true;
    return { value: input, done: false };
  };
  this._releaseLock = () => {
    if (doneReading) {
      try {
        doneReadingSet.add(input);
      } catch(e) {}
    }
  };
}
function Reader(input) {
  this.stream = input;
  if (input[externalBuffer]) {
    this[externalBuffer] = input[externalBuffer].slice();
  }
  let streamType = streams.isStream(input);
  if (streamType === 'node') {
    input = streams.nodeToWeb(input);
  }
  if (streamType) {
    const reader = input.getReader();
    this._read = reader.read.bind(reader);
    this._releaseLock = () => {
      reader.closed.catch(function() {});
      reader.releaseLock();
    };
    return;
  }
  let doneReading = false;
  this._read = async () => {
    if (doneReading || doneReadingSet.has(input)) {
      return { value: undefined, done: true };
    }
    doneReading = true;
    return { value: input, done: false };
  };
  this._releaseLock = () => {
    if (doneReading) {
      try {
        doneReadingSet.add(input);
      } catch(e) {}
    }
  };
}
function Reader ( input ) { this . stream = input ; if ( input [ externalBuffer ] ) { this [ externalBuffer ] = input [ externalBuffer ] . slice ( ) ; } let streamType = streams . isStream ( input ) ; if ( streamType === 'node' ) { input = streams . nodeToWeb ( input ) ; } if ( streamType ) { const reader = input . getReader ( ) ; this . _read = reader . read . bind ( reader ) ; this . _releaseLock = ( ) => { reader . closed . catch ( function ( ) { } ) ; reader . releaseLock ( ) ; } ; return ; } let doneReading = false ; this . _read = async ( ) => { if ( doneReading || doneReadingSet . has ( input ) ) { return { value : undefined , done : true } ; } doneReading = true ; return { value : input , done : false } ; } ; this . _releaseLock = ( ) => { if ( doneReading ) { try { doneReadingSet . add ( input ) ; } catch ( e ) { } } } ; }
A wrapper class over the native ReadableStreamDefaultReader.
This additionally implements pushing back data on the stream, which
lets us implement peeking and a host of convenience functions.
It also lets you read data other than streams, such as a Uint8Array.
@class
A wrapper class over the native ReadableStreamDefaultReader . This additionally implements pushing back data on the stream which lets us implement peeking and a host of convenience functions . It also lets you read data other than streams such as a Uint8Array .