Wondering what’s next for npm?Check out our public roadmap! »

what

0.0.2 • Public • Published

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 = require('what');
 
// some example
fs.stat('what?', what);
    /* prints out:
     * callback(
     *   `{ [Error: ENOENT, stat 'w…` => Error
     * );
     */
 
// successful case of above
fs.stat('./index.js', what);
    /* prints out:
     * callback(
     *   `null` => Error (guessed)
     *   `{ dev: 12345678,  mode: 3…` => object
     * );
     */

what can also do a couple more tricks:

// prints out a formatted function header
what.params(fs.stat);
    /* prints out:
     * function <anonymous>(path,callback);
     */
 
// gets some info on a function, like the function name (if any), parameter names, and function body
what.info(fs.stat);
    /* 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' }
     */

Install

npm i what

DownloadsWeekly Downloads

3

Version

0.0.2

License

ISC

Last publish

Collaborators

  • avatar