Home

Awesome

acorn-extract-comments npmjs.com The MIT License

Extract JavaScript code comments from a string, using acorn.

code climate standard code style travis build status coverage status dependency status

Install

npm i acorn-extract-comments --save

Usage

For more use-cases see the tests

const extract = require('acorn-extract-comments')

acornExtractComments

Extract all code comments, including block/line and also these that are marked as "ignored" like (//! and /*!)

Params

Example

const fs = require('fs')
const extract = require('acorn-extract-comments')

const str = fs.readFileSync('./index.js', 'utf8')
const comments = extract(str, {})
// => ['array', 'of', 'all', 'code', 'comments']

.line

Extract only line comments.

Params

Example

const comments = extract(str, {block: false})
// => ['array', 'of', 'line', 'comments']

or through method

const comments = extract.line(str)
// => ['all', 'line', 'comments']

.block

Extract only block comments.

Params

Examples

const comments = extract(str, {line: false})
// => ['array', 'of', 'block', 'comments']

or through method

const comments = extract.block(str)
// => ['array', 'of', 'block', 'comments']

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github