Home

Awesome

acorn-strip-comments npmjs.com The MIT License

Strip code comments from a string, using acorn javascript parser.

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

Install

npm i acorn-strip-comments --save

Usage

For more use-cases see the tests

const acornStripComments = require('acorn-strip-comments')

acornStripComments

Strip all code comments, but not these that are marked as "ignored" like (//! and /*!).
Pass opts.preserve: false to remove even them.

Params

Example

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

const str = fs.readFileSync('./index.js', 'utf8')
const output = strip(str, {})
// => modified and cleaned string

.line

Remove only line comments.

Params

Examples

const output = strip(str, {block: false})
// => modified and cleaned string

or through method

const output = strip.line(str)
// => modified and cleaned string

.block

Remove only block comments.

Params

Examples

const output = strip(str, {line: false})
// => modified and cleaned string

or through method

const output = strip.block(str)
// => modified and cleaned string

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