目前,有什么方法可以检查我的脚本是否在 deno 中作为模块被调用?
Is there any way, as of current, to check if my script is being called as a module in deno?
正如标题所说。例如,我可以在节点中检查以下内容:
if(process.main===module) console.log('This is being called as a module');
目前有什么方法可以让我在 deno 中检查相同的东西吗?
您可以使用 import.meta.main
,如果从模块中调用,它将是 false
。
正如标题所说。例如,我可以在节点中检查以下内容:
if(process.main===module) console.log('This is being called as a module');
目前有什么方法可以让我在 deno 中检查相同的东西吗?
您可以使用 import.meta.main
,如果从模块中调用,它将是 false
。