看一下express
框架中的随机source file个,我不明白其中有两行代码(这些代码是几乎所有NodeJS文件的典型代码).
/**
* Expose `Router` constructor.
*/
exports = module.exports = Router;
和
/**
* Expose HTTP methods.
*/
var methods = exports.methods = require('./methods');
I underst和 that the first piece of code allows the rest of the functions in the file to be exposed to the NodeJS app, but I don't underst和 exactly how it works, or what the code in the line means.
What do
exports
和module.exports
actually mean?
我相信第二段代码允许文件中的函数访问methods
,但同样,它是如何做到这一点的.
Basically, what are these magic words: module
和 exports
?