I am trying to figure out how to not to exports the private functions when using functions in the objects.
For example, in modules.js I have the following:
const modelType1 = require('./Message/type1');
module.exports = {
Type1: modelType1
}
type1.js
look like this:
const Message = {
publicFunction: function() {
return 'hello!';
},
privateFunction: function() {
return 'hello!';
}
}
module.exports = Message;
How to not to export privateFunction
?
When I tried to different approach without using an object which I have got it to work, for example:
const modelType2 = require('./Message/type2');
module.exports = {
Type2: modelType2
}
type2.js
look like this:
function publicFunction() {
return "Hello"
}
function privateFunction() {
return "Hello"
}
module.exports = {
publicFunction
}
Which is best practice to use type1.js
or type2.js
and what the difference between them two?