Javascript 在Node.js中导出文件的整个范围

Javascript 在Node.js中导出文件的整个范围,javascript,node.js,Javascript,Node.js,我制作了一个可以在服务器端使用的游戏引擎,并计划使用Node.js运行它 引擎整体打包到一个文件中,最后,我将其导出如下: module.exports = Irenic; //Irenic is just the name of the engine. This is actually an object housing most of the classes and functions. 但是,如果我在Irenic对象之外创建了一些函数,会怎么样?例如,我重新定义了setInterval和

我制作了一个可以在服务器端使用的游戏引擎,并计划使用Node.js运行它

引擎整体打包到一个文件中,最后,我将其导出如下:

module.exports = Irenic; //Irenic is just the name of the engine. This is actually an object housing most of the classes and functions.
但是,如果我在
Irenic
对象之外创建了一些函数,会怎么样?例如,我重新定义了
setInterval
setTimeout
函数来跟踪有多少超时/间隔处于活动状态,现在我重新认识到,我将无法在引擎所在的文件之外使用它们

如何导出文件中的所有内容?(我已经尝试了
module.exports=this;
,但无效。导出了一个空对象。)


编辑1:我希望能够简单地
call()
我包含引擎的文件中的函数,而不是像
exportedObj.call()

这样做。您可以将引擎+函数包装到导出的对象中

module.exports = {engine: Irenic, fun: function(){...} ... }
var-engine=require('./irenic')。engine,fun=engine.fun
将允许您自己使用
引擎
乐趣
等。