Skip to content
/ what Public

utility callback to help determine function parameters in poorly documented libraries

Notifications You must be signed in to change notification settings

tangmi/what

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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' }
     */

About

utility callback to help determine function parameters in poorly documented libraries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published