index.js
function process (stream, chunk, output, fn) {
  stream._parserBytesLeft -= chunk.length;
  debug('%o bytes left for stream piece', stream._parserBytesLeft);

  if (stream._parserState === BUFFERING) {
    // buffer
    stream._parserBuffers.push(chunk);
    stream._parserBuffered += chunk.length;
  } else if (stream._parserState === PASSTHROUGH) {
    // passthrough
    output(chunk);
  }
  // don't need to do anything for the SKIPPING case

  if (0 === stream._parserBytesLeft) {
    // done with stream "piece", invoke the callback
    var cb = stream._parserCallback;
    if (cb && stream._parserState === BUFFERING && stream._parserBuffers.length > 1) {
      chunk = Buffer.concat(stream._parserBuffers, stream._parserBuffered);
    }
    if (stream._parserState !== BUFFERING) {
      chunk = null;
    }
    stream._parserCallback = null;
    stream._parserBuffered = 0;
    stream._parserState = INIT;
    stream._parserBuffers.splice(0); // empty

    if (cb) {
      var args = [];
      if (chunk) {
        // buffered
        args.push(chunk);
      } else {
        // passthrough
      }
      if (output) {
        // on a Transform stream, has "output" function
        args.push(output);
      }
      var async = cb.length > args.length;
      if (async) {
        args.push(trampoline(fn));
      }
      // invoke cb
      var rtn = cb.apply(stream, args);
      if (!async || fn === rtn) return fn;
    }
  } else {
    // need more bytes
    return fn;
  }
}
function process (stream, chunk, output, fn) {
  stream._parserBytesLeft -= chunk.length;
  debug('%o bytes left for stream piece', stream._parserBytesLeft);

  if (stream._parserState === BUFFERING) {
    // buffer
    stream._parserBuffers.push(chunk);
    stream._parserBuffered += chunk.length;
  } else if (stream._parserState === PASSTHROUGH) {
    // passthrough
    output(chunk);
  }
  // don't need to do anything for the SKIPPING case

  if (0 === stream._parserBytesLeft) {
    // done with stream "piece", invoke the callback
    var cb = stream._parserCallback;
    if (cb && stream._parserState === BUFFERING && stream._parserBuffers.length > 1) {
      chunk = Buffer.concat(stream._parserBuffers, stream._parserBuffered);
    }
    if (stream._parserState !== BUFFERING) {
      chunk = null;
    }
    stream._parserCallback = null;
    stream._parserBuffered = 0;
    stream._parserState = INIT;
    stream._parserBuffers.splice(0); // empty

    if (cb) {
      var args = [];
      if (chunk) {
        // buffered
        args.push(chunk);
      } else {
        // passthrough
      }
      if (output) {
        // on a Transform stream, has "output" function
        args.push(output);
      }
      var async = cb.length > args.length;
      if (async) {
        args.push(trampoline(fn));
      }
      // invoke cb
      var rtn = cb.apply(stream, args);
      if (!async || fn === rtn) return fn;
    }
  } else {
    // need more bytes
    return fn;
  }
}
function process ( stream , chunk , output , fn ) { stream . _parserBytesLeft -= chunk . length ; debug ( '%o bytes left for stream piece' , stream . _parserBytesLeft ) ; if ( stream . _parserState === BUFFERING ) { // buffer stream . _parserBuffers . push ( chunk ) ; stream . _parserBuffered += chunk . length ; } else if ( stream . _parserState === PASSTHROUGH ) { // passthrough output ( chunk ) ; } // don't need to do anything for the SKIPPING case if ( 0 === stream . _parserBytesLeft ) { // done with stream "piece", invoke the callback var cb = stream . _parserCallback ; if ( cb && stream . _parserState === BUFFERING && stream . _parserBuffers . length > 1 ) { chunk = Buffer . concat ( stream . _parserBuffers , stream . _parserBuffered ) ; } if ( stream . _parserState !== BUFFERING ) { chunk = null ; } stream . _parserCallback = null ; stream . _parserBuffered = 0 ; stream . _parserState = INIT ; stream . _parserBuffers . splice ( 0 ) ; // empty if ( cb ) { var args = [ ] ; if ( chunk ) { // buffered args . push ( chunk ) ; } else { // passthrough } if ( output ) { // on a Transform stream, has "output" function args . push ( output ) ; } var async = cb . length > args . length ; if ( async ) { args . push ( trampoline ( fn ) ) ; } // invoke cb var rtn = cb . apply ( stream , args ) ; if ( ! async || fn === rtn ) return fn ; } } else { // need more bytes return fn ; } }
The internal `process` function gets called by the `data` function when
something "interesting" happens. This function takes care of buffering the
bytes when buffering, passing through the bytes when doing that, and invoking
the user callback when the number of bytes has been reached.

@api private
The internal process function gets called by the data function when something interesting happens . This function takes care of buffering the bytes when buffering passing through the bytes when doing that and invoking the user callback when the number of bytes has been reached .