process-bridge.js
function parseMessageLines(lines, getLine, cb) {
  var matches, line, lineParts;

  if (arguments.length < 3) {
    cb = getLine;
    getLine = false;
  }

  RE_MESSAGE_LINE.lastIndex = 0;
  while ((matches = RE_MESSAGE_LINE.exec(lines))) {
    line = matches[1];
    lines = matches[2];
    if (line === '') {
      continue;
    } else if (getLine) {
      cb(line); // eslint-disable-line callback-return
    } else {
      lineParts = line.split('\t', 2);
      if (lineParts.length < 2 || !lineParts[0] || !lineParts[1]) {
        throw new Error('Invalid message: ' + line);
      }
      cb(+lineParts[0], JSON.parse(lineParts[1])); // eslint-disable-line callback-return
    }
  }
  return lines;
}
function parseMessageLines(lines, getLine, cb) {
  var matches, line, lineParts;

  if (arguments.length < 3) {
    cb = getLine;
    getLine = false;
  }

  RE_MESSAGE_LINE.lastIndex = 0;
  while ((matches = RE_MESSAGE_LINE.exec(lines))) {
    line = matches[1];
    lines = matches[2];
    if (line === '') {
      continue;
    } else if (getLine) {
      cb(line); // eslint-disable-line callback-return
    } else {
      lineParts = line.split('\t', 2);
      if (lineParts.length < 2 || !lineParts[0] || !lineParts[1]) {
        throw new Error('Invalid message: ' + line);
      }
      cb(+lineParts[0], JSON.parse(lineParts[1])); // eslint-disable-line callback-return
    }
  }
  return lines;
}
function parseMessageLines ( lines , getLine , cb ) { var matches , line , lineParts ; if ( arguments . length < 3 ) { cb = getLine ; getLine = false ; } RE_MESSAGE_LINE . lastIndex = 0 ; while ( ( matches = RE_MESSAGE_LINE . exec ( lines ) ) ) { line = matches [ 1 ] ; lines = matches [ 2 ] ; if ( line === '' ) { continue ; } else if ( getLine ) { cb ( line ) ; // eslint-disable-line callback-return } else { lineParts = line . split ( '\t' , 2 ) ; if ( lineParts . length < 2 || ! lineParts [ 0 ] || ! lineParts [ 1 ] ) { throw new Error ( 'Invalid message: ' + line ) ; } cb ( + lineParts [ 0 ] , JSON . parse ( lineParts [ 1 ] ) ) ; // eslint-disable-line callback-return } } return lines ; }
Extract & normalize an IPC message from current input stream lines, and return remaining data.
@param {string} lines - current input stream.
@param {boolean} [getLine] - Get a line as plain string.
@param {procMessage|Function} cb - Callback function that is called. It is called with a line if `getLine` is `true`.
@returns {string} remaining data.
Extract & normalize an IPC message from current input stream lines and return remaining data .