uncommentify

A through stream that removes comments from js

npm install uncommentify
4 downloads in the last week
9 downloads in the last month

uncommentify

A through stream that removes comments with falafel.

example

// Strip banner comments from js
var strip = require('uncommentify')();
var fs = require('fs');
fs.createReadStream('index.js')
  .pipe(strip)
  .pipe(fs.createWriteStream('no-banner-comments.js'));
// Strip ALL comments from js
var strip = require('uncommentify')({
  all: true,
});
var fs = require('fs');
fs.createReadStream('index.js')
  .pipe(strip)
  .pipe(fs.createWriteStream('no-comments.js'));
// Strip comments synchronously
var strip = require('uncommentify').sync;
var fs = require('fs');
var uncommented = strip(fs.readFileSync('index.js'), {all:true});

Example Banner Comments

By default, uncommentify will just remove the first found banner comment.

/* I am 
a block
 * banner comment */
// I am 
// a line
// banner comment
/*! I will not be removed even though Im a banner comment unless you force me. */

options

var strip = require('uncommentify')({
  all: false,
  force: false,
  line: true,
  block: true,
});

all

Removes all comments.

force

Will remove comments that begin with /*! or //! which are not normally removed.

line

Set to false to not remove // line comments.

block

Set to false to not remove /* block */ comments.

releases

  • 0.1.1 - add sync
  • 0.1.0 - initial release

license

MIT

npm loves you