Node.js NodeJS模块得到编译

Node.js NodeJS模块得到编译,node.js,time,Node.js,Time,我创建了一个简单的nodejs模块,返回当前时间 它只在第一次调用后工作,第一次调用后它将被缓存并返回第一次调用值 这是我的模块: module.exports.Time = Math.floor(Date.now() / 1000); 将其定义为返回时间的函数 module.exports.Time = function(){ return Math.floor(Date.now()/1000}; //Other file var anything = require("path/file

我创建了一个简单的nodejs模块,返回当前时间

它只在第一次调用后工作,第一次调用后它将被缓存并返回第一次调用值

这是我的模块:

module.exports.Time = Math.floor(Date.now() / 1000);

将其定义为返回时间的函数

module.exports.Time = function(){ return Math.floor(Date.now()/1000};

//Other file
var anything = require("path/file.js");
anything.Time();

将其定义为返回时间的函数

module.exports.Time = function(){ return Math.floor(Date.now()/1000};

//Other file
var anything = require("path/file.js");
anything.Time();