title: Is it possible to import variables in JavaScript (node.js)?
body: <p>I have variables in <strong><code>app.js</code></strong>:</p>
  
  <pre><code>var G = {};
  module.exports = G;
  
  var DATA = G.DATA = 'DATA';
  var F1 = G.F1　= function(val)
  {
    return val;
  };
  </code></pre>
  
  <p>In this manner, I can export variables under the object <code>G</code>, and at the same time, can access the variable directly writing <code>DATA</code> without <code>G.</code> prefix.</p>
  
  <p>So far so good.</p>
  
  <p>Now, I want to run a <em>test</em> for <code>app.js</code> in <strong><code>test.js</code></strong>:</p>
  
  <pre><code>var G = require('./app.js');
  console.log(G.DATA);  // -&gt; DATA
  </code></pre>
  
  <p>This works, but I also want to access the variable directly writing <code>DATA</code> without <code>G.</code> prefix like <code>console.log(DATA);  // -&gt; DATA</code></p>
  
  <p>Surely, I could do like</p>
  
  <p><code>var DATA = G.DATA;</code> for every variables(property) export&amp;required module <code>G</code> object, but obviously it's a tedious process to add every variable to the test file manually to correspond the <code>G</code> objects.</p>
  
  <p>Is there any way to do this automatically?</p>
  
  <p>So far, I'm pessmistic since</p>
  
  <p>JS <code>function</code> encloses <code>var</code> in the own scope, so in theory there's no way to have a helper function to <code>var</code> for every object property. </p>
  
  <p>Thanks.</p>
  
  <p>PS. I would like to avoid any <code>eval</code> or <code>VM</code> of node solution. I have tried them in past, and too much problems. </p>