B2G/gaia/apps/email/js/ext/mailapi/imap/probe.js
/**
 * Split the contents of a buffer on CRLF pairs, retaining the CRLF's on all but
 * the first line. In other words, ret[1] through ret[ret.length-1] will have
 * CRLF's.  The last entry may or may not have a CRLF.  The last entry will have
 * a non-zero length.
 *
 * This logic is very specialized to its one caller...
 */
Split the contents of a buffer on CRLF pairs, retaining the CRLF's on all but
the first line. In other words, ret[1] through ret[ret.length-1] will have
CRLF's.  The last entry may or may not have a CRLF.  The last entry will have
a non-zero length.

This logic is very specialized to its one caller
Split the contents of a buffer on CRLF pairs retaining the CRLF ' s on all but the first line . In other words ret [ 1 ] through ret [ ret . length - 1 ] will have CRLF ' s . The last entry may or may not have a CRLF . The last entry will have a non - zero length . This logic is very specialized to its one caller
function customBufferSplitCRLF(buf) {
  var ret = [];
  var effLen = buf.length - 1, start = 0;
  for (var i = 0; i < effLen;) {
    if (buf[i] === 13 && buf[i + 1] === 10) {
      if (ret.length) {
        i += 2;
        ret.push(buf.slice(start, i));
      }
      else {
        ret.push(buf.slice(start, i));
        i += 2;
      }
      start = i;
    }
    else {
      i++;
    }
  }
  if (!ret.length)
    ret.push(buf);
  else if (start < buf.length)
    ret.push(buf.slice(start, buf.length));
  return ret;
}
function customBufferSplitCRLF ( buf ) { var ret = [ ] ; var effLen = buf . length - 1 , start = 0 ; for ( var i = 0 ; i < effLen ; ) { if ( buf [ i ] === 13 && buf [ i + 1 ] === 10 ) { if ( ret . length ) { i += 2 ; ret . push ( buf . slice ( start , i ) ) ; } else { ret . push ( buf . slice ( start , i ) ) ; i += 2 ; } start = i ; } else { i ++ ; } } if ( ! ret . length ) ret . push ( buf ) ; else if ( start < buf . length ) ret . push ( buf . slice ( start , buf . length ) ) ; return ret ; }
Split the contents of a buffer on CRLF pairs, retaining the CRLF's on all but
 the first line.
Split the contents of a buffer on CRLF pairs retaining the CRLF ' s on all but the first line .
// do include the CRLF in the entry if this is not the first one.