strip-debug-option

4.0.1 • Public • Published

Strip console, alert, and debugger statements from JavaScript code

Useful for making sure you didn't leave any logging in production code.

Usage

$ npm install strip-debug-option

Usage

const stripDebug = require('strip-debug-option');
 
const option={
    skipDebugger:false,
    skipConsole:false,
    skipAlert:false
}
 
stripDebug('function foo(){console.log("foo");alert("foo");debugger;}',option).toString();
//=> 'function foo(){void 0;void 0;}'

API

stripDebug(input)

Returns the modified Esprima AST which can be used to make additional modifications.

Call .toString() to get the stringified output.

To prevent any side-effects, console.*/alert* is replaced with void 0 instead of being stripped.

If you shadow the console global with your own local variable, it will still be removed.

input

Type: string Object

Pass in a string of JavaScript code or a Esprima compatible AST.

License

MIT

Package Sidebar

Install

npm i strip-debug-option

Weekly Downloads

302

Version

4.0.1

License

MIT

Unpacked Size

3.58 kB

Total Files

4

Last publish

Collaborators

  • saminn.liu