index.js
function checkUntil(resultWithData, data, ended) {
      let desiredLength;
      try {
        desiredLength = until(resultWithData, data, ended);
      } catch (errUntil) {
        doReject(errUntil, true);
        return true;
      }

      const resultLength = result ? result.length : 0;
      if (typeof desiredLength === 'number') {
        if (desiredLength > resultLength) {
          debug(
            'until returned a desired length of %d.  '
              + 'Only have %d.  Reading up to %d.',
            desiredLength, resultLength, desiredLength
          );
          numSize = desiredLength;
          size = desiredLength - resultLength;
        } else if (desiredLength >= 0) {
          debug(
            'until returned a desired length of %d out of %d',
            desiredLength, resultLength
          );
          if (desiredLength < resultLength) {
            if (ended) {
              debug('Unable to unshift:  Can not unshift after end.');
            } else {
              result = tryUnshift(stream, result, desiredLength, true);
            }
          }
          doResolve();
          return true;
        } else {
          debug('until returned %d, continuing to read', desiredLength);
        }
      } else if (desiredLength === true) {
        debug('until returned true, read finished.');
        doResolve();
        return true;
      } else if (desiredLength !== undefined
          && desiredLength !== null
          && desiredLength !== false) {
        // Note:  Although this could be allowed, it causes an Error so that
        // future versions may add behavior for these values without causing
        // breakage.
        doReject(
          new TypeError(
            `non-numeric, non-boolean until() result: ${desiredLength}`
          ),
          true
        );
      } else {
        debug('until returned %s, continuing to read', desiredLength);
      }

      return false;
    }
function checkUntil(resultWithData, data, ended) {
      let desiredLength;
      try {
        desiredLength = until(resultWithData, data, ended);
      } catch (errUntil) {
        doReject(errUntil, true);
        return true;
      }

      const resultLength = result ? result.length : 0;
      if (typeof desiredLength === 'number') {
        if (desiredLength > resultLength) {
          debug(
            'until returned a desired length of %d.  '
              + 'Only have %d.  Reading up to %d.',
            desiredLength, resultLength, desiredLength
          );
          numSize = desiredLength;
          size = desiredLength - resultLength;
        } else if (desiredLength >= 0) {
          debug(
            'until returned a desired length of %d out of %d',
            desiredLength, resultLength
          );
          if (desiredLength < resultLength) {
            if (ended) {
              debug('Unable to unshift:  Can not unshift after end.');
            } else {
              result = tryUnshift(stream, result, desiredLength, true);
            }
          }
          doResolve();
          return true;
        } else {
          debug('until returned %d, continuing to read', desiredLength);
        }
      } else if (desiredLength === true) {
        debug('until returned true, read finished.');
        doResolve();
        return true;
      } else if (desiredLength !== undefined
          && desiredLength !== null
          && desiredLength !== false) {
        // Note:  Although this could be allowed, it causes an Error so that
        // future versions may add behavior for these values without causing
        // breakage.
        doReject(
          new TypeError(
            `non-numeric, non-boolean until() result: ${desiredLength}`
          ),
          true
        );
      } else {
        debug('until returned %s, continuing to read', desiredLength);
      }

      return false;
    }
function checkUntil ( resultWithData , data , ended ) { let desiredLength ; try { desiredLength = until ( resultWithData , data , ended ) ; } catch ( errUntil ) { doReject ( errUntil , true ) ; return true ; } const resultLength = result ? result . length : 0 ; if ( typeof desiredLength === 'number' ) { if ( desiredLength > resultLength ) { debug ( 'until returned a desired length of %d.  ' + 'Only have %d.  Reading up to %d.' , desiredLength , resultLength , desiredLength ) ; numSize = desiredLength ; size = desiredLength - resultLength ; } else if ( desiredLength >= 0 ) { debug ( 'until returned a desired length of %d out of %d' , desiredLength , resultLength ) ; if ( desiredLength < resultLength ) { if ( ended ) { debug ( 'Unable to unshift:  Can not unshift after end.' ) ; } else { result = tryUnshift ( stream , result , desiredLength , true ) ; } } doResolve ( ) ; return true ; } else { debug ( 'until returned %d, continuing to read' , desiredLength ) ; } } else if ( desiredLength === true ) { debug ( 'until returned true, read finished.' ) ; doResolve ( ) ; return true ; } else if ( desiredLength !== undefined && desiredLength !== null && desiredLength !== false ) { // Note:  Although this could be allowed, it causes an Error so that // future versions may add behavior for these values without causing // breakage. doReject ( new TypeError ( ` ${ desiredLength } ` ) , true ) ; } else { debug ( 'until returned %s, continuing to read' , desiredLength ) ; } return false ; }
Calls the until function and handles its result.
@return {boolean} <code>true</code> if done reading, <code>false</code>
otherwise.
@private
Calls the until function and handles its result .