I would like to process/parse and alter some Javascript code, preferably in a regular expression if that's possible (open to suggestions). The purpose would be to insert a new code snippet after each statement in the JS.
For example:
The original Javascript:
while(true){
Utils.log("hello world");
Utils.sleep(1000);
}
Code snippet that I would like to insert:
checkPause();
So the new code would look like this:
while(true){
checkPause();
Utils.log("hello world");
checkPause();
Utils.sleep(1000);
checkPause();
}
checkPause();
The example above is quite simple, but the real JS code could be more complex and could even be minified. The code could also miss out some semicolons ;