
var esprima = require('esprima');


/**
 * Position in the source file.
 *
 * @see [SpiderMonkey Parser API]
 *   {@link https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API}
 *
 * @typedef {Object} Position
 * @property {number} line - Line number, 1-indexed.
 * @property {?number} column - Column number, 0-indexed.
 */


/**
 * Location - position range.
 *
 * @typedef {Object} Location
 * @property {Position} start
 * @property {Position} end
 */


/**
 * Extract comments from code.
 * Each comment is represented by a string within its usual comment delimiters.
 * Returned location always contains both line and column info.
 *
 * @arg {string} code - JavaScript code.
 * @return {{text: string, loc: Location}[]}
 */
var extract = function (code) {
  return esprima.parse(code, {
    comment: true,
    loc: true
  }).comments.map(function (comment) {
    return {
      text: (comment.type == 'Line')
        ? '//' + comment.value
        : '/*' + comment.value + '*/',
      loc: comment.loc
    };
  });
};


module.exports = extract;

@@ -1,13 +1,12 @@
-%0A
 var esprima 
@@ -447,36 +447,94 @@
 tart
-%0A * @property %7BPosition%7D end
+ - Column number must be set.%0A * @property %7BPosition%7D end - Column number must be set.
 %0A */
@@ -655,72 +655,8 @@
 rs.%0A
- * Returned location always contains both line and column info.%0A
  *%0A 

Make column numbers in Location mandatory