Skip to content

Instantly share code, notes, and snippets.

@tj tj/debug.js
Created Jan 4, 2011

Embed
What would you like to do?
require.registerExtension('.js', function(js){
return js.replace(/^ *\/\/debug: */gm, '');
});
if (options.debug) require('./debug');
while (iAmParsingStuff) {
//debug: console.log('state -> %s', this.state)
}
@aheckmann

This comment has been minimized.

Copy link

aheckmann commented Jan 4, 2011

sweeeeeeet

@polotek

This comment has been minimized.

Copy link

polotek commented Jan 4, 2011

Haha, nice. This could be a feature supported by node.

@tj

This comment has been minimized.

Copy link
Owner Author

tj commented Jan 5, 2011

yeah that would be cool, just require('debug') to enable. Highly doubt anything like it would ever get in haha, but its a nice alternative to having actual conditionals scattered throughout your lib slowing it down

@DTrejo

This comment has been minimized.

Copy link

DTrejo commented Jan 6, 2011

Did you happen to test how much slower? Just curious.

@tj

This comment has been minimized.

Copy link
Owner Author

tj commented Jan 6, 2011

nah, it only has an effect when required so it doesnt really matter, and it would only affect the initial boot

@tj

This comment has been minimized.

Copy link
Owner Author

tj commented Jan 6, 2011

oh, you meant the extra function calls? it depends. writing a streaming parser an extra function call or two could add up quite a bit if you parse 50kb, that could be 50k calls that you dont want :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.