https://github.com/wangtao0101/parse-comment-es6
A fast comment parse for es6 without dependence, support loc and range
https://github.com/wangtao0101/parse-comment-es6
commnet es6 javascript parser
Last synced: about 1 year ago
JSON representation
A fast comment parse for es6 without dependence, support loc and range
- Host: GitHub
- URL: https://github.com/wangtao0101/parse-comment-es6
- Owner: wangtao0101
- License: mit
- Created: 2017-05-21T07:41:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-13T01:53:37.000Z (almost 9 years ago)
- Last Synced: 2025-03-04T08:49:13.609Z (over 1 year ago)
- Topics: commnet, es6, javascript, parser
- Language: JavaScript
- Homepage:
- Size: 328 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parse-comment-es6
[](https://www.npmjs.com/package/parse-comment-es6)
[](https://travis-ci.org/wangtao0101/parse-comment-es6)
A new comment parse for es6
## Install
```
npm install parse-comment-es6 --save
yarn add parse-comment-es6
```
## Usage
```
import strip from 'parse-comment-es6';
const p = '`aaa`\n//abc\n';
console.log(strip(p, { comment: true, range: true, loc: true, raw: true }));
// =>
// text: '`aaa`\n\n',
// comments: [
// {
// type: 'LineComment',
// raw: '//abc'
// loc: {
// start: {
// line: 1,
// column: 0,
// },
// end: {
// line: 1,
// column: 5,
// },
// },
// range: {
// start: 6,
// end: 11,
// },
// }
// ]
// };
```
## Option
| Property | Description | Type | Default |
|-----------|------------------------------------------|------------|--------|
| comment | need to return comment list | boolean | false
| raw | need to return comment raw, comment option should be true | boolean | false
| loc | need to return comment loc, comment option should be true | boolean | false
| range | need to return comment range, comment option should be true | boolean | false
## Test
test past using jquery, react, react-dom
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/wangtao0101/parse-comment-es6/issues).