Actually, I dont give a fulcrum if you are, I am fed up with this crap!
You should be able to define variables and functions as normal, and then export them to the module.exports with simple call:
// simply one call
export( funcName, variName, etCetera )
// declare funcName -function
// declare var variName
// etc...
- Two fold problem:
- access the arguments -object and generate an object like:
{ funcName: funcName,
variName: variName,
etCetera: etCetera
}
- problems: when passing values to function as arguments, variables are expressions
- iow the arg object ends up with the value, not variable reference
- Simplest solution is to use an array of strings (at least for vars)
- bind this object to module.exports dynamically
function bindObjToThisExport( obj ) {
this.exports = ob;
};
bindObjectToThis.apply( module, theRefsObject )
Solution model - Pseudocode - (Untested)
function exportsToContext() {
var alen = arguments
for (var a = 0; a < alen; a++) {
this.exports[el] = arguments[a]);
});
}
var foo = 1, bar = 2, zoo = function() { return "z" };
function export( argArr ) {
exportsToContext.apply( module, [this].join( argArr) );
}