I have to export 2 type of constants and few functions like getUser.
mymodule.js
const type1 = require('./constants1.js');
const type2 = require('./constants2.js');
module.exports = Object.freeze(Object.assign(Object.create(null), type1, type2))
constants1.js
module.exports = Object.freeze({
DOUBLE: 1,
FLOAT: 2
})
consumer.js
const udb = require('./mymodule.js');
console.log(udb.DOUBLE);
Now I also want to export function like getUser , how do i change mymodule.js to export the functions too , so that consumer.js can call udb.getUser
something like this but it doesnt work, Please suggest.
module.exports = Object.freeze(Object.assign(Object.create(null), type1, type2)), getUser: function() {}