/** * Extract code comments from the given `string`. * * ```js * var extract = require('babel-extract-comments'); * console.log(extract('// this is a code comment')); * // [{ type: 'CommentBlock', * // value: '!\n * babel-extract-comments <https://github.com/jonschlinkert/babel-extract-comments>\n *\n * * // Copyright (c) 2014-2018, Jon Schlinkert.\n * Released under the MIT License.\n ', * // start: 0, * // end: 173, * // loc: SourceLocation { start: [Position], end: [Position] } }] * ``` * @param {String} `string` String of javascript * @return {Array} Array of code comment objects. * @api public */ function extract(str, options) { const res = babylon.parse(str, options); return res.comments; }