I have a function:
fs.readFile = function(filename, callback) {
// implementation code.
};
Sometime later I want to see the signature of th
I am not sure what you want but try looking at the console log of this fiddle, it prints entire function definition. I am looking at chrome console.log output.
var fs = fs || {};
fs.readFile = function(filename, callback) {
alert(1);
};
console.log(fs.readFile);
DEMO http://jsfiddle.net/K7DMA/
In node.js specifically, you have to convert the function to string before logging:
$ node
> foo = function(bar, baz) { /* codez */ }
[Function]
> console.log(foo)
[Function]
undefined
> console.log(foo.toString())
function (bar, baz) { /* codez */ }
undefined
>
or use a shortcut like foo+""
If what you mean by "function signature" is how many arguments it has defined, you can use:
function fn (one) {}
console.log(fn.length); // 1
All functions get a length property automatically.