I have a JavaScript function which accepts a function as a parameter, like this:
var myFunction = function(funParameter) {
// funParameter is a function
};
I can call this function like this:
myFunction(function (aParameter, anotherOne) {
// do stuff
});
Inside the body of myFunction, how can I retrieve the parameters that funParameter is supposed to receive? I want to know the parameters declared with the function passed to myFunction (in the above case, I want to know the the parameter function accepts aParameter and anotherOne.
Only way I know of doing this is by parsing appropriately funParameter.toString(), but I feel like it's kind of hacky.
It should be like in Mocha tests:
it('should test something synchronously', function () {...});
it('should test something asynchronously', function (done) {
// test...
done();
});
You have to be able to behave differently if the function you pass to it accepts a done parameter or not.
toString... AFAIK no there's no other way .itfunction from the Mocha test suit: how the hell do they do that?