Created
January 9, 2011 03:28
-
-
Save tj/771388 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Module dependencies. | |
*/ | |
var inspect = require('sys').inspect; | |
console.inspect = function(obj, depth){ | |
if (!obj) return; | |
var cons = obj.constructor | |
, name = cons.name | |
, proto = obj.__proto__ | |
, depth = depth || 0 | |
, indent = Array(depth + 1).join(' '); | |
if (0 == depth) { | |
if ('function' == typeof obj) { | |
name = '[' + name + ': ' + obj.name + ']'; | |
} else { | |
name = '[' + name + ']'; | |
} | |
} | |
console.log(indent + '\033[33m%s\033[0m', name); | |
Object.keys(obj).sort().forEach(function(key){ | |
var desc = Object.getOwnPropertyDescriptor(obj, key); | |
if (desc.get) console.log(indent + ' \033[90m.%s\033[0m', key); | |
if (desc.set) console.log(indent + ' \033[90m.%s=\033[0m', key); | |
if ('function' == typeof desc.value) { | |
var str = desc.value.toString(); | |
var params = str.match(/^function *\((.*?)\)/) | |
, val = params | |
? params[1].split(/ *, */).map(function(param){ | |
return '\033[0m' + param + '\033[90m'; | |
}).join(', ') | |
: ''; | |
console.log(indent + ' \033[90m.%s(%s)\033[0m', key, val); | |
} else if (undefined !== desc.value) { | |
console.log(indent + ' \033[90m.%s %j\033[0m', key, desc.value); | |
} | |
}); | |
console.inspect(proto, ++depth); | |
}; | |
var Stream = require('net').Stream; | |
console.inspect(new Stream) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Stream] | |
._readImpl(buf, off, len, calledByIOWatcher) | |
._shutdownImpl() | |
._writeImpl(buf, off, len, fd, flags) | |
.fd null | |
.secure false | |
.type null | |
Stream | |
._checkForSecureHandshake() | |
._shutdown() | |
._writeOut(data, encoding, fd) | |
._writeQueueLast() | |
.address() | |
.close(data, encoding) | |
.connect() | |
.destroy(exception) | |
.end(data, encoding) | |
.flush() | |
.forceClose(e) | |
.getCipher() | |
.getPeerCertificate(credentials) | |
.open(fd, type) | |
.pause() | |
.resume() | |
.send() | |
.setEncoding(encoding) | |
.setKeepAlive(enable, time) | |
.setNoDelay(v) | |
.setSecure(credentials) | |
.setTimeout(msecs) | |
.verifyPeer() | |
.write(data, encoding, fd) | |
EventEmitter | |
.addListener(type, listener) | |
.emit(type) | |
.listeners(type) | |
.on(type, listener) | |
.removeAllListeners(type) | |
.removeListener(type, listener) | |
Object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Stream = require('net').Stream; | |
console.inspect(new Stream) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment