In a node.js module a variable declaration stays private inside the module:
var a = 'x';
Let's say, I want to declare a number of variables in this manner. I cannot use the following code, because like this the variables become really global and visible in other modules as well:
var xs = ['a', 'b', 'c', 'd'];
for (key in xs) {
var value = xs[key];
global[value] = 'x';
}
Is there a way to do this just for the module? I need this because I am requiring a library ('gl-matrix'), which itself has several sub-objects I need to access in the module easily. I want to avoid:
var gl_matrix = require('gl-matrix');
var vec2 = gl_matrix.vec2;
var vec3 = gl_matrix.vec3;
var mat3 = gl_matrix.mat3;
[...]