cleanify

0.0.4 • Public • Published

Cleanify

Nodejs module for stripping single/multiline comments from string/s.

Install:

npm install cleanify

To run tests enter module dir and run:

node test.js

Usage:

var fs = require('fs');
var Cleanify = require('cleanify');

/*
 * Choose literal string skip type:
 *   SINGLE: skip only single quoted strings -> 'b//la'
 *   DOUBLE: skip only double quoted strings -> "b//a"
 *   MULTI: skip both string types -> "b//la" 'b//a'
 */
var cleanify = new Cleanify(Cleanify.SINGLE);
var cleanify = new Cleanify(Cleanify.DOUBLE);
var cleanify = new Cleanify(Cleanify.MULTI);

// Multi is default
var cleanify = new Cleanify();

var lol = fs.readFileSync('./test/lol.js', 'utf8');

// One argument -> return stripped string
var string = cleanify.strip(lol);

// require() can load .json but comments are not allowed
var wtf = fs.readFileSync('./test/wtf.json', 'utf8');
var oh = fs.readFileSync('./test/oh.txt', 'utf8');

// More then one arguments -> return array of stripped strings
var array = cleanify.strip(lol, oh, wtf);

console.log('string: ' + string);
console.log('array: ' + JSON.stringify(array));

Readme

Keywords

none

Package Sidebar

Install

npm i cleanify

Weekly Downloads

1

Version

0.0.4

License

none

Last publish

Collaborators

  • sipware