index.js
function parse(content, options) {
  options = options || {};

  options = defaults(options, {
    addEsprimaInfo: false,
    parseJsDocTags: true,
    hideJsDocTags: true,
    trim: true
  });
  
  var comments = [];
  
  var ast = esprima.parse(content, {
    tolerant: true,
    comment:  true,
    tokens:   true,
    range:    true,
    loc:      true
  }).comments;
  
  for (var i = 0; i < ast.length; i++) {
    var node = ast[i];
    var lines = node.value.replace(/\r\n/g,'\n').split('\n');
    
    var comment = {
      start: node.loc.start.line,
      end: node.loc.end.line
    };
    
    if (options.addEsprimaInfo) {
      comment.node = node;
    }

    comment.jsDoc = !!(lines[0] && lines[0].trim && '*' === lines[0].trim());
    comment.lines = formatLines(lines, comment.jsDoc, options.trim);
    comment.tags  = [];
    
    if (options.parseJsDocTags) {
      applyJsDocTags(comment, options.hideJsDocTags);
      if (options.hideJsDocTags) {
        comment.lines = arrayTrim(comment.lines);
      }
    }
    
    comments.push(comment);
  }
  
  return comments;
}
function parse(content, options) {
  options = options || {};

  options = defaults(options, {
    addEsprimaInfo: false,
    parseJsDocTags: true,
    hideJsDocTags: true,
    trim: true
  });
  
  var comments = [];
  
  var ast = esprima.parse(content, {
    tolerant: true,
    comment:  true,
    tokens:   true,
    range:    true,
    loc:      true
  }).comments;
  
  for (var i = 0; i < ast.length; i++) {
    var node = ast[i];
    var lines = node.value.replace(/\r\n/g,'\n').split('\n');
    
    var comment = {
      start: node.loc.start.line,
      end: node.loc.end.line
    };
    
    if (options.addEsprimaInfo) {
      comment.node = node;
    }

    comment.jsDoc = !!(lines[0] && lines[0].trim && '*' === lines[0].trim());
    comment.lines = formatLines(lines, comment.jsDoc, options.trim);
    comment.tags  = [];
    
    if (options.parseJsDocTags) {
      applyJsDocTags(comment, options.hideJsDocTags);
      if (options.hideJsDocTags) {
        comment.lines = arrayTrim(comment.lines);
      }
    }
    
    comments.push(comment);
  }
  
  return comments;
}
function parse ( content , options ) { options = options || { } ; options = defaults ( options , { addEsprimaInfo : false , parseJsDocTags : true , hideJsDocTags : true , trim : true } ) ; var comments = [ ] ; var ast = esprima . parse ( content , { tolerant : true , comment : true , tokens : true , range : true , loc : true } ) . comments ; for ( var i = 0 ; i < ast . length ; i ++ ) { var node = ast [ i ] ; var lines = node . value . replace ( / \r\n / g , '\n' ) . split ( '\n' ) ; var comment = { start : node . loc . start . line , end : node . loc . end . line } ; if ( options . addEsprimaInfo ) { comment . node = node ; } comment . jsDoc = ! ! ( lines [ 0 ] && lines [ 0 ] . trim && '*' === lines [ 0 ] . trim ( ) ) ; comment . lines = formatLines ( lines , comment . jsDoc , options . trim ) ; comment . tags = [ ] ; if ( options . parseJsDocTags ) { applyJsDocTags ( comment , options . hideJsDocTags ) ; if ( options . hideJsDocTags ) { comment . lines = arrayTrim ( comment . lines ) ; } } comments . push ( comment ) ; } return comments ; }
Return array of comment objects
@param {string}  content
@param {Object}  [options]
@param {boolean} [options.addEsprimaInfo=false] Add node object which
is generated by Esprima
@param {boolean} [options.parseJsDocTags=true]
@param {boolean} [options.hideJsDocTags=true] False to remove lines
with jsdoc tags
@param {boolean} [options.trim=true] true, false, 'right'
@returns {Array<{start, end, lines, jsDoc, tags}>}
Return array of comment objects