Skip to content

Instantly share code, notes, and snippets.

@tj
Created July 31, 2013 18:48
Show Gist options
  • Save tj/6124922 to your computer and use it in GitHub Desktop.
Save tj/6124922 to your computer and use it in GitHub Desktop.
console.api()
function params(fn) {
var str = fn.toString();
var sig = str.match(/\(([^)]*)\)/)[1];
if (!sig) return [];
return sig.split(', ');
}
console.api = function(obj){
console.log();
var proto = Object.getPrototypeOf(obj);
console.log(' %s:', obj.constructor.name);
for (var key in proto) {
if (proto.hasOwnProperty(key)) {
console.log(' - %s(%s)', key, params(proto[key]).join(', '));
}
}
console.log();
};
Item:
- isNew()
- toJSON()
- file(file)
- link(url)
- remove(fn)
- set(prop, val, fn)
- load(fn)
- create(fn)
- thumb(path, fn)
- postFile(fn)
- postURL(fn)
- save(fn)
@tj
Copy link
Author

tj commented Jul 31, 2013

(i know it could be a module but small tmp stuff like this loses utility if you have to go install/require it everywhere first)

@paulkon
Copy link

paulkon commented Jul 31, 2013

This is neat. Will be using this for my constructors so that I can reformat and/or remove prototype functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment