如何列出节点js脚本中的所有函数?

Tri*_*daz 6 javascript reflection node.js

我试过看global,但它只包含变量,而不是函数.如何列出脚本中创建的所有函数?

ear*_*ils 5

使用要查看的文件从命令行运行节点调试.然后你可以使用list(这里有一些大号)

node debug mini_file_server.js 
< debugger listening on port 5858
connecting... ok
debug> scripts
  26: mini_file_server.js
debug> list(1000)
  1 var http = require('http'),
  2     util = require('util'),
  3     fs   = require('fs');
  4 
  5 server = http.createServer(function(req, res){  
  6     var stream  = fs.createReadStream('one.html'),
  7         stream2 = fs.createReadStream('two.html');
  8     console.log(stream);
  9     console.log(stream2);
 10     stream.on('end', function(){
 11         stream2.pipe(res, { end:false});
 12     });
 13 
 14     stream2.on('end', function(){
 15         res.end("Thats all!");
 16     });
 17 
 18     res.writeHead(200, {'Content-Type' : 'text/plain'});
 19     stream.pipe(res, { end:false});
 20     stream2.pipe(res, { end:true});
 21 
 22 }).listen(8001);
 23 });
debug> 
Run Code Online (Sandbox Code Playgroud)


小智 1

cli: http: //nodejs.org/docs/v0.3.7/api/debugger.html

图形用户界面: https: //github.com/dannycoates/node-inspector

还有https://github.com/c4milo/node-webkit-agent正在开发中,这将是节点检查器的更强大版本。