[英]How to get all external functions used in node js module
Given a node js package, I can find packages it is dependant on. 给定一个节点js包,我可以找到它所依赖的包。 For each of the dependencies, how can I get the exports that current package uses ?
对于每个依赖项,如何获取当前程序包使用的导出?
Example: In a javascript file, I have following lines of code 示例:在一个javascript文件中,我有以下几行代码
var async = require('async');
......
async.mapSeries(files, function (entry, done) {
......
I want to be able to extract out that this js uses mapSeries function from async 我希望能够从异步中提取出此js使用mapSeries函数
You could relatively easily do it with esprima
, for example, but like @DaveNewton said you might miss some, due to the very dynamic nature of JS, and the fact that exports
can be modified many different ways. 例如,您可以使用
esprima
相对容易地做到这esprima
,但就像@DaveNewton所说的那样,由于JS的动态特性,并且可以用许多不同的方式修改exports
的事实,您可能会错过一些。
Not only will you have to "run the code" for complete, bullet-proof list, you would also have to run it with 100% coverage. 您不仅需要“运行代码”以获取完整的防弹列表,而且还必须以100%的覆盖率运行它。 Not really something worth doing, probably.
可能不是真的值得做的事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.