code: function fold(object, max) {
    var result = '',
        position = 0,
        length = object.length,
        trailing = /\n+$/.exec(object),
        newLine;
  
    if (trailing) {
      length = trailing.index + 1;
    }
  
    while (position < length) {
      newLine = object.indexOf('\n', position);
      if (newLine > length || newLine === -1) {
        if (result) {
          result += '\n\n';
        }
        result += foldLine(object.slice(position, length), max);
        position = length;
      } else {
        if (result) {
          result += '\n\n';
        }
        result += foldLine(object.slice(position, newLine), max);
        position = newLine + 1;
      }
    }
    if (trailing && trailing[0] !== '\n') {
      result += trailing[0];
    }
  
    return result;
  }
docs: The `trailing` var is a regexp match of any trailing `\n` characters.  There are three cases we care about:  1. One trailing `\n` on the string.  Just use `|` or `>`. This is the assumed default. (trailing = null) 2. No trailing `\n` on the string.  Use `|-` or `>-` to "chomp" the end. 3. More than one trailing `\n` on the string.  Use `|+` or `>+`.  In the case of `>+`, these line breaks are *not* doubled (like the line breaks within the string), so it's important to only end with the exact same number as we started.