{"id":15674530,"url":"https://github.com/jonschlinkert/esprima-extract-comments","last_synced_at":"2025-08-04T03:33:53.622Z","repository":{"id":21103870,"uuid":"24404269","full_name":"jonschlinkert/esprima-extract-comments","owner":"jonschlinkert","description":"Extract javascript code comments with esprima. Thin wrapper to prove a simple interface for getting code comments from a string, file or glob of files.","archived":false,"fork":false,"pushed_at":"2018-02-12T11:21:57.000Z","size":297,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-11T22:47:52.745Z","etag":null,"topics":["ast","comments","esprima","extract","javascript","nodejs","parse"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-24T07:01:44.000Z","updated_at":"2023-09-27T23:31:49.000Z","dependencies_parsed_at":"2022-09-18T06:56:21.212Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/esprima-extract-comments","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jonschlinkert/esprima-extract-comments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fesprima-extract-comments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fesprima-extract-comments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fesprima-extract-comments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fesprima-extract-comments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/esprima-extract-comments/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fesprima-extract-comments/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268644501,"owners_count":24283336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","comments","esprima","extract","javascript","nodejs","parse"],"created_at":"2024-10-03T15:46:20.903Z","updated_at":"2025-08-04T03:33:53.601Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esprima-extract-comments [![NPM version](https://img.shields.io/npm/v/esprima-extract-comments.svg?style=flat)](https://www.npmjs.com/package/esprima-extract-comments) [![NPM monthly downloads](https://img.shields.io/npm/dm/esprima-extract-comments.svg?style=flat)](https://npmjs.org/package/esprima-extract-comments) [![NPM total downloads](https://img.shields.io/npm/dt/esprima-extract-comments.svg?style=flat)](https://npmjs.org/package/esprima-extract-comments) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/esprima-extract-comments.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/esprima-extract-comments)\n\n\u003e Extract code comments from string or from a glob of files using esprima.\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 esprima-extract-comments\n```\n\n## Breaking changes in v1.0.0!\n\n* line `comment.type` was changed from `line` to `LineComment`\n* block `comment.type` was changed from `block` to `BlockComment`\n\n## Usage\n\nAdd to your Node.js/JavaScript project with the following line of code:\n\n```js\nconst extract = require('esprima-extract-comments');\n```\n\n## API\n\n### [extract](index.js#L30)\n\nExtract line and block comments from a string of JavaScript.\n\n**Params**\n\n* `string` **{String}**\n* `options` **{Object}**: Options to pass to [esprima](http://esprima.org).\n* `returns` **{Array}**: Array of code comment objects.\n\n**Example**\n\n```js\nconsole.log(extract('// this is a line comment'));\n// [ { type: 'Line',\n//     value: ' this is a line comment',\n//     range: [ 0, 25 ],\n//     loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 25 } } } ]\n```\n\n### [.file](index.js#L52)\n\nExtract code comments from a JavaScript file.\n\n**Params**\n\n* `file` **{String}**: Filepath to the file to parse.\n* `options` **{Object}**: Options to pass to [esprima](http://esprima.org).\n* `returns` **{Array}**: Array of code comment objects.\n\n**Example**\n\n```js\nconsole.log(extract.file('some-file.js'), { cwd: 'some/path' });\n// [ { type: 'Line',\n//     value: ' this is a line comment',\n//     range: [ 0, 25 ],\n//     loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 25 } } } ]\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\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 \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\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 \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [extract-comments](https://www.npmjs.com/package/extract-comments): Uses esprima to extract line and block comments from a string of JavaScript. Also optionally… [more](https://github.com/jonschlinkert/extract-comments) | [homepage](https://github.com/jonschlinkert/extract-comments \"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* [js-comments](https://www.npmjs.com/package/js-comments): Parse JavaScript code comments and generate API documentation. | [homepage](https://github.com/jonschlinkert/js-comments \"Parse JavaScript code comments and generate API documentation.\")\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### 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._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fesprima-extract-comments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fesprima-extract-comments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fesprima-extract-comments/lists"}