0.0.3 • Published 10 years ago

minimize-calls v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

minimize-calls

Remove function calls or strip arguments in javascript code. Useful for removing debug messages in a production build. The next step after using this small tool, would be to compress the code with something like UglifyJS.

Uses Recast for parsing the code.

Example

invariant(isArray(obj), "obj should be an array!");

...becomes...

invariant(isArray(obj));

Usage

var minimizeCalls = require('minimize-calls');

var min = minimizeCalls(testCode, [
	// removes all console.*() calls
	{ test: /^console./, removeCall: true },
	
	// keeps only the argument at index 0 at calls to invariant()
	{ test: /^invariant$/, keepArgs: [0] },
	
	// drops all arguments to invariant()
	{ test: /^invariant$/, keepArgs: [] },
	
	// drops the argument at index 1, and keeps the rest
	{ test: /^invariant$/, stripArgs: [1] }
]);

console.log(min.code);

See the tests for more details.

Install

npm install minimize-calls

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago