Socket
Socket
Sign inDemoInstall

strip-debug-option

Package Overview
Dependencies
12
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    strip-debug-option

Strip console, alert, and debugger statements from JavaScript code


Version published
Weekly downloads
241
decreased by-6.95%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 06 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc