Reputation: 3026
in nodejs i can export functions like so :-
modules.exports = function() {
return {
func1 : function() {
...
...
},
func1 : function() {
...
...
}
}
}
is it possible to export a non function so I can use it like so?
var foo = require('bar');
var x = foo.func1();
var y = foo.property1;
Upvotes: 0
Views: 3216
Reputation: 120
in your file to import put the following line :
module.export.var = "value";
and in your code
var foo = require('bar');
console.log(foo.var);
Upvotes: 1
Reputation: 1156
Yes, just add it to your returned object:
modules.exports = function() {
return {
func1 : function() {
...
...
},
func1 : function() {
...
...
},
property1: 'Some value'
}
}
Upvotes: 3