{"name":"extract-comments","description":"Extract code comments from string or from a glob of files.","version":"0.5.1","homepage":"https://github.com/jonschlinkert/extract-comments","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/extract-comments.git"},"bugs":{"url":"https://github.com/jonschlinkert/extract-comments/issues"},"licenses":[{"type":"MIT","url":"https://github.com/jonschlinkert/extract-comments/blob/master/LICENSE"}],"files":["index.js","lib/"],"main":"index.js","engines":{"node":">=0.10"},"scripts":{"test":"mocha","lint":"deps -e test,fixtures && verb"},"devDependencies":{"mocha":"~1.18.2","should":"^4.0.4"},"dependencies":{"map-files":"^0.3.0"},"keywords":["code","parse","javascript","block","context","comments","comment","extract","esprima","glob"],"gitHead":"c57181e8ad0a29c86546c660f78b1bc8fa889dfe","_id":"extract-comments@0.5.1","_shasum":"12f5359fef9e96bb6a2885df92a4b08aa313c469","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"12f5359fef9e96bb6a2885df92a4b08aa313c469","tarball":"http://registry-npm.ywwl.com/extract-comments/download/extract-comments-0.5.1.tgz","integrity":"sha512-tOZHUvNjYggQcHwY3XgrjHNBUs+m0rP67aALxoLlq9LCvZ7cMf0B6B0AGVi7HXR4QkoNUkoOqRCOXVHaMSlLkQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCMvYC9jn5uDyxdcyDOo7rxSj8HBCqMivM1NoXHsPfcegIgfhjStGap34p4c9tCa0IjlQRzI3rAnxw3IRPskrTv/8M="}],"size":2319,"noattachment":false,"key":"/extract-comments/-/extract-comments-0.5.1.tgz"},"directories":{},"readme":"# extract-comments [![NPM version](https://img.shields.io/npm/v/extract-comments.svg?style=flat)](https://www.npmjs.com/package/extract-comments) [![NPM monthly downloads](https://img.shields.io/npm/dm/extract-comments.svg?style=flat)](https://npmjs.org/package/extract-comments) [![NPM total downloads](https://img.shields.io/npm/dt/extract-comments.svg?style=flat)](https://npmjs.org/package/extract-comments) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/extract-comments.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/extract-comments)\n\n> Uses esprima to extract line and block comments from a string of JavaScript. Also optionally parses code context (the next line of code after a comment).\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save extract-comments\n```\n\n## Usage\n\n```js\nvar extract = require('extract-comments');\n\n// pass a string of JavaScript\nextract(string);\n```\n\n**Example**\n\n```js\nvar str = '/**\\n * this is\\n *\\n * a comment\\n*/\\n\\n\\nvar foo = \"bar\";\\n';\nvar comments = extract(str);\nconsole.log(comments);\n\n[{\n  type: 'block',\n  raw: '/**\\n * this is\\n *\\n * a comment\\n*/',\n  value: 'this is\\na comment',\n  loc: { start: { line: 1, column: 0 }, end: { line: 5, column: 33 } },\n  code:\n   { line: 7,\n     loc: { start: { line: 7, column: 36 }, end: { line: 7, column: 52 } },\n     value: 'var foo = \"bar\";' }\n```\n\n## Extractors\n\nBy default, [esprima](http://esprima.org) is used for extracting comments. This can easily be changed by passing a function to `options.extractor`.\n\n**The easy way**\n\nUse a published module, such as:\n\n* [babel-extract-comments](https://github.com/jonschlinkert/babel-extract-comments)\n* [esprima-extract-comments](https://github.com/jonschlinkert/esprima-extract-comments)\n* [espree-extract-comments](https://github.com/jonschlinkert/espree-extract-comments)\n\nExample:\n\n```js\nextract(str, {extractor: require('babel-extract-comments')});\n```\n\nIf you create a compatible extractor, feel free to do pr [or create an issue](https://github.com/jonschlinkert/extract-comments/issues/new) to add it to the readme!\n\n**Roll your own**\n\n```js\nextract(str, {\n  extractor: function(str) {\n    // must return an array of tokens with:\n    // - type: 'Block', 'CommentBlock', 'Line' or 'CommentLine'\n    // - value: the comment inner string\n    // - loc: with `start` and `end` line and column\n    // example:\n    return [\n      { \n        type: 'Block',\n        {start: { line: 1, column: 0 },\n          end: { line: 5, column: 33 }},\n        value: ' this is a comment string '\n      }\n    ];\n  }\n});\n```\n\n## API\n\n### [extract](index.js#L26)\n\nExtract comments from the given `string`.\n\n**Params**\n\n* `string` **{String}**\n* `options` **{Object}**: Pass `first: true` to return after the first comment is found.\n* `tranformFn` **{Function}**: (optional) Tranform function to modify each comment\n* `returns` **{Array}**: Returns an array of comment objects\n\n**Example**\n\n```js\nconst extract = require('extract-comments');\nconsole.log(extract(string, options));\n```\n\n### [.block](index.js#L44)\n\nExtract block comments from the given `string`.\n\n**Params**\n\n* `string` **{String}**\n* `options` **{Object}**: Pass `first: true` to return after the first comment is found.\n* `returns` **{String}**\n\n**Example**\n\n```js\nconsole.log(extract.block(string, options));\n```\n\n### [.line](index.js#L61)\n\nExtract line comments from the given `string`.\n\n**Params**\n\n* `string` **{String}**\n* `options` **{Object}**: Pass `first: true` to return after the first comment is found.\n* `returns` **{String}**\n\n**Example**\n\n```js\nconsole.log(extract.line(string, options));\n```\n\n### [.first](index.js#L78)\n\nExtract the first comment from the given `string`.\n\n**Params**\n\n* `string` **{String}**\n* `options` **{Object}**: Pass `first: true` to return after the first comment is found.\n* `returns` **{String}**\n\n**Example**\n\n```js\nconsole.log(extract.first(string, options));\n```\n\n## Release history\n\n**v0.10.0**\n\n* Parsing is now handled by esprima, so only JavaScript can be parsed. I'm working on parsers for other languages and will cross-link those here when they're pushed up.\n* Breaking change: since parsing is now done by esprima, on both the line and block comment objects, the `loc.start.pos` and `loc.end.pos` properties have been renamed to `loc.start.column` and `loc.end.column`.\n\n**v0.9.0**\n\n* Breaking change: `lines` property was removed from `Block` comments, since this can easily be done by splitting `value`\n\n## About\n\n<details>\n<summary><strong>Contributing</strong></summary>\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n</details>\n\n<details>\n<summary><strong>Running Tests</strong></summary>\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install && npm test\n```\n\n</details>\n\n<details>\n<summary><strong>Building docs</strong></summary>\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n</details>\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [babel-extract-comments](https://www.npmjs.com/package/babel-extract-comments): Uses babel (babylon) to extract JavaScript code comments from a JavaScript string or file. | [homepage](https://github.com/jonschlinkert/babel-extract-comments \"Uses babel (babylon) to extract JavaScript code comments from a JavaScript string or file.\")\n* [code-context](https://www.npmjs.com/package/code-context): Parse a string of javascript to determine the context for functions, variables and comments based… [more](https://github.com/jonschlinkert/code-context) | [homepage](https://github.com/jonschlinkert/code-context \"Parse a string of javascript to determine the context for functions, variables and comments based on the code that follows.\")\n* [espree-extract-comments](https://www.npmjs.com/package/espree-extract-comments): Uses espree to extract JavaScript code comments from a string. Returns an array of comment… [more](https://github.com/jonschlinkert/espree-extract-comments) | [homepage](https://github.com/jonschlinkert/espree-extract-comments \"Uses espree to extract JavaScript code comments from a string. Returns an array of comment objects, with line, column, index, comment type and comment string.\")\n* [esprima-extract-comments](https://www.npmjs.com/package/esprima-extract-comments): Extract code comments from string or from a glob of files using esprima. | [homepage](https://github.com/jonschlinkert/esprima-extract-comments \"Extract code comments from string or from a glob of files using esprima.\")\n* [parse-comments](https://www.npmjs.com/package/parse-comments): Parse code comments from JavaScript or any language that uses the same format. | [homepage](https://github.com/jonschlinkert/parse-comments \"Parse code comments from JavaScript or any language that uses the same format.\")\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 93 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 3 | [cazzer](https://github.com/cazzer) |\n| 1 | [architectcodes](https://github.com/architectcodes) |\n\n### Author\n\n**Jon Schlinkert**\n\n* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 12, 2018._","publish_time":1423864095185,"_cnpm_publish_time":1423864095185,"dist-tags":{"latest":"1.1.0"}}