比较两个在结构上类似的JS文件中的等效功能?

发布于 2025-02-11 22:14:26 字数 462 浏览 1 评论 0原文

是否有一种方法可以比较两个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪落纷纷 2025-02-18 22:14:26

我建议您找到一个代码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....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文