Is there anything equivarent to Python’s ‘from foobar import *’ in Node.js?
Now I wrote the following code:
var foobar = require('foobar'),
func1 = foobar.func1,
gvar2 = foobar.gvar2,
const3 = foobar.const3;
I think this is ugly, because a lot of names appeared twice.
Python provides smart solution which removes duplications:
from foobar import func1, gvar2, const3
Does Node.js provide similar way?
No, it does not; at least, I am not aware of any way to do this easily.
Node uses the CommonJS module system, which requires a function,
require, that returns an exported API for a module.