AturSams
AturSams

Reputation: 7962

Regex for finding all javascript functions including arrow notation?

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

Answers (2)

philipp
philipp

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

Tezra
Tezra

Reputation: 8833

Using Google Chrome (assuming universal compliance)...

  1. Hit F12 to open developer console
  2. Find the "Performance" tab and click on it.
  3. Hit record or Ctrl + E to start / stop recording. Chrome will give you everything you need to know. :3

(PS. Just sell your soul to Google! ^w^)

Upvotes: 0

Related Questions