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.
(or)function. I meanobj={fn() {}}. I don't think there's a way to find these with regex, you would need a Javascript parser.