> net.Socket.toString()
'function Socket(options) {\n if (!(this instanceof Socket)) return new Socket(options);\n\n this._connecting = false;\n this._handle = null;\n\n switch (typeof options) {\n case \'number\':\n options = { fd: options }; // Legacy interface.\n break;\n case \'undefined\':\n options = {};\n break;\n }\n\n stream.Duplex.call(this, options);\n\n if (options.handle) {\n this._handle = options.handle; // private\n } else if (typeof options.fd !== \'undefined\') {\n this._handle = createPipe();\n this._handle.open(options.fd);\n this.readable = options.readable !== false;\n this.writable = options.writable !== false;\n } else {\n // these will be set once there is a connection\n this.readable = this.writable = false;\n }\n\n this.onend = null;\n\n // shut down the socket when we\'re finished with it.\n this.on(\'finish\', onSocketFinish);\n this.on(\'_socketEnd\', onSocketEnd);\n\n initSocketHandle(this);\n\n this._pendingData = null;\n this._pendingEncoding = \'\';\n\n // handle strings directly\n this._writableState.decodeStrings = false;\n\n // default to *not* allowing half open sockets\n this.allowHalfOpen = options && options.allowHalfOpen || false;\n\n // if we have a handle, then start the flow of data into the\n // buffer. if not, then this will happen when we connect\n if (this._handle && options.readable !== false)\n this.read(0);\n}'
去 node_modules 下看 module 的程序源码
为什么我的安装目录下的C:\Program Files\nodejs\node_modules\下就只有npm一个文件夹,没有安装时自带的那些模块呢?
@didiaoyu 安装的时候失败了
例如我要看預設模塊util有什麼function可以用, 可以這麼做
或是配合tab
嗯,这个方法看模块的function挺不错的! 有没有看function的参数的办法呢? 谢谢!
@zhs077 没有呀,我运行都很正常的!
@didiaoyu
如果要看懂一個 function 裡的參數做什麼, 你還是得看 function的整個程式碼, 或是他有寫註解了
function有幾個參數
印出function
@hankwang 在交互模式下,toString()打印出的方法常常是省略号加行号,看不全
@hankwang 嗯,好的,很好用,谢谢!
@jimokanghanchao
我的不會省略耶?
@hankwang ^^ 说错了,准确来讲是交互模式不省略, node debug模式时,执行repl,toString打印的方法是省略的。