比较两个在结构上类似的JS文件中的等效功能?
是否有一种方法可以比较两个JavaScript文件的等效功能?例如:
const foo = 1
console.log(foo)
并且
const bar = 1
console.log(bar)
在功能上被认为是等效的。
我不需要确定所有情况下的等价性。处理基本名称更改足以满足我当前的用例(并且可能解决了大多数以后的用例,也可能解决了大多数使用情况)。
我唯一的想法是可能使用具有可预测的命名混淆的缩影。例如,遇到的名字总是被音译到v1
,第二个到v2
等。我意识到我可以创建解析器或其他东西,最终可以做到这一点,但是我希望找到现有的解决方案。
Is there a method to compare two javascript files for equivalent functionality? E.g.:
const foo = 1
console.log(foo)
and
const bar = 1
console.log(bar)
would be considered functionally equivalent.
I don't need to determine equivalence in all situations. Handling basic name changes is enough for my current use case (and probably solves most if not all future use cases).
My only thought is to maybe use a minifier with predictable naming obfuscation. Like, the first name encountered is always transliterated to v1
, the 2nd to v2
, etc. I realize I could create instrument a parser or something and could do that eventually, but I was hoping to find an existing solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您找到一个代码pla窃工具像这样的人检查相似性。
我知道有些人发现我们的Java 2教授的工具可以处理更改的变量名称,但我不知道他使用了什么。
I would recommend finding a code plagiarism tool like this one to check for similarity.
I know some people who found out that our Java 2 professor's tool could handle changing variable names, but I don't know what he used....