code: function trim(text) {
    var MAX_INDENT = 9999;
    var empty = RegExp.prototype.test.bind(/^\s*$/);
    var lines = text.split('\n');
    var minIndent = MAX_INDENT;
    var indentRegExp;
    var ignoreLine = (lines[0][0] != ' '  && lines.length > 1);
    // ignore first line if it has no indentation and there is more than one line
  
    lines.forEach(function(line){
      if (ignoreLine) {
        ignoreLine = false;
        return;
      }
  
      var indent = line.match(/^\s*/)[0].length;
      if (indent > 0 || minIndent == MAX_INDENT) {
        minIndent = Math.min(minIndent, indent);
      }
    });
  
    indentRegExp = new RegExp('^\\s{0,' + minIndent + '}');
  
    for ( var i = 0; i < lines.length; i++) {
      lines[i] = lines[i].replace(indentRegExp, '');
    }
  
    // remove leading lines
    while (empty(lines[0])) {
      lines.shift();
    }
  
    // remove trailing
    while (empty(lines[lines.length - 1])) {
      lines.pop();
    }
    return lines.join('\n');
  }
docs: ////////////////////////////////////////////////////////