what
utility callback to help determine the parameters in poorly documented libraries
install
npm install --save what # omit `--save` if you want to prevent yourself from deploying bad debugging code
usage
drop what
in as a callback to see how it's called by a library. what
will print out any parameters it's passed as well as try and figure out what type they are.
var what = ; // some examplefs; /* prints out: * callback( * `{ [Error: ENOENT, stat 'w…` => Error * ); */ // successful case of abovefs; /* prints out: * callback( * `null` => Error (guessed) * `{ dev: 12345678, mode: 3…` => object * ); */
what
can also do a couple more tricks:
// prints out a formatted function headerwhat; /* prints out: * function <anonymous>(path,callback); */ // gets some info on a function, like the function name (if any), parameter names, and function bodywhat; /* returns this object: * { name: null, * params: [ 'path', 'callback' ], * body: '\n callback = makeCallback(callback);\n if (!nullCheck(path, callback)) return;\n binding.stat(pathModule._makeLong(path), callback);\n' } */