node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org »

strip-debug

strip-debug Build Status

Strip console, alert, and debugger statements from JavaScript code

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

Also available as Gulp/Grunt/Broccoli plugins.

Usage

$ npm install strip-debug

Usage

const stripDebug = require('strip-debug');
 
stripDebug('function foo(){console.log("foo");alert("foo");debugger;}').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.

input

Type: string Object

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

Related

License

MIT © Sindre Sorhus