Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
Last active December 17, 2015 08:19
Show Gist options
  • Save sindresorhus/5579216 to your computer and use it in GitHub Desktop.
Save sindresorhus/5579216 to your computer and use it in GitHub Desktop.
Wrap method calls in console.time
var falafel = require('falafel');
var src = 'test();';
var output = falafel(src, function (node) {
if (node.type === 'CallExpression') {
var parent = node.parent;
var funcName = node.callee.name;
parent.update('console.time(\'' + funcName + '()\');' + parent.source() + 'console.timeEnd(\'' + funcName + '()\');');
}
});
console.log(output);
// console.time('test()');test();console.timeEnd('test()');
@robertkowalski
Copy link

require.extensions is deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment