简体   繁体   English

如何获取节点js模块中使用的所有外部函数

[英]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.

相关问题 Node js模块如何获取导出函数列表 - Node js module how to get list of exported functions 将JS移动到外部文件时,无法让控件使用我的任何JS函数以使其正常工作 - Cannot get any of my JS functions used by controls to work when the JS is moved to an external file 如何在 scope 中为 nuxt 中的其他外部 js 函数获取外部 js 文件函数? - How can I get external js file functions in scope for other external js functions in nuxt? 我将所有内容保存在一个外部.js文件中。 但并非所有功能都在每个页面上使用。 这会影响速度吗? - I keep everything in an external .js file. But not all functions are used on every page. Does this affect speed? 如何正确要求节点模块,并导出其中的所有功能 - How to properly require a node module, exporting all the functions in it 如何设置回调并传递node.js模块函数变量 - How to set callback and pass node.js module functions variables Node.js模块中的上下文-如何通过反射访问函数? - Context in Node.js module - How to access functions with reflection? 如何分配在所有js文件功能中使用的const? - how assign a const to be used in all js file functions? 如何获取页面中使用的所有外部或内部CSS? - How to get all external or internal css used in page? 如何列出节点 js 脚本中的所有函数? - How can I list all the functions in my node js script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM