0

Follow up question to the solution posted here:

Adding console.log to every function automatically

This works great for getting the name of the function called:

function augment(withFn) {
var name, fn;
for (name in window) {
    fn = window[name];
    if (typeof fn === 'function') {
        window[name] = (function(name, fn) {
            var args = arguments;
            return function() {
                withFn.apply(this, args);
                return fn.apply(this, arguments);

            }
        })(name, fn);
    }
  }
}

Can you also list the arguments supplied to the function that was called?

1 Answer 1

1

If you read the code, you can see that fn is being called with arguments, and that is what you want in your function. So just add it to args :

withFn.apply(this, Array.from(args).concat([arguments]));
Sign up to request clarification or add additional context in comments.

1 Comment

Aha -thanks. I knew the arguments were there but wasn't concatenating. Cheers. For any who are doing this in Max/MSP - Array.from(args) is not available - so use arrayfromargs(args) instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.