Reputation: 7962
I'd like to programatically find all javascript functions and add some code for profiling purposes (to count how many times they are called). Is there any existing tool or a regex to do that?
It is relatively easy to write something like:
function\s+\w+\(.*?\)\s*{
But that only begins to cover the multitude of options.
Upvotes: 2
Views: 167
Reputation: 16505
I have tried something similar and came to the result that a regex is not the weapon of choice for that.
But I would recommend you to have a look here and create a Plugin for Babel. In step 3 »generation« you can probably modify all functions.
Upvotes: 2
Reputation: 8833
Using Google Chrome (assuming universal compliance)...
(PS. Just sell your soul to Google! ^w^)
Upvotes: 0