I am using node.js. I would written several javascript functions to be shared across several files. I want to put these functions into a single file tools.js
. Based on the answer in
In Node.js, how do I "include" functions from my other files?
the functions need to be declared in this format (function expressions);
// tools.js
// ========
module.exports = {
foo: function () {
// whatever
},
bar: function () {
// whatever
}
};
However, the functions I have written are of this format;
function foo(a, b, c)
{
//do whatever
}
I have several such functions. It is a chore to re-declare all of them in tools.js
as function expressions. Is it possible to have tools.js
use functions declared in my way?