code: function write(buffer) {
  
      // first, trim trailing whitespace for fast searching
      buffer = buffer.replace(/[ \t]+$/gm, '')
  
      // compact lines if emptyLines != -1
      if (_elines >= 0)
        buffer = trimBuffer(buffer)
  
      if (!buffer) return
  
      // finished the surrounding lines, now the inners
      if (!_elines) {
        // remove empty lines and change eols in one unique operation
        buffer = buffer.replace(/\n{2,}/g, _to)
      }
      else {
        // keep max n empty lines (n+1 sucesive eols), -1 keep all
        if (_elines > 0)
          buffer = buffer.replace(_re, '$1')
  
        // change line terminator if not unix
        if (_to !== '\n') buffer = buffer.replace(/\n/g, _to)
      }
  
      // apply indentation, regex `^.` with `/m` matches non-empty lines
      if (_indent)
        buffer = buffer.replace(/^./mg, _indent + '$&')
  
      _lastch = buffer.slice(-1)
      // istanbul ignore else
      if (output)
        output.emit('data', buffer)
    }
docs: On new data, trim trailing whitespace and normalize eols