I have the following redacted code:
module.exports = {
read: read,
write: write,
};
var read = function(parameters, config, next) {
/* <snip> */
};
var write = function(parameters, config, next) {
/* <snip> */
};
If I go to require()
this file elsewhere, it will crash node and say that the required object has no method read
or write
. Wouldn't variable hoisting pull the functions above the modules.export = { ... };
?
module.exports
assignments? Ismodule
some special node object that gets declared and hoisted before any other code in the file is rendered? – Guide