Reputation: 403
I'm designing an art tool for a project and I've created a set of types of properties that brush could have. Things such as an number for the size of the brush, dropdowns, booleans, images, etc. Each of these has a few methods associated with them and they're stored in one file. The file structure is basically
var property1 = {
...
}
var property2 = {
...
}
....
modules.exports = property1,property2;
I'm now working on creating a variety of default brushes so I have a prototype and a bunch of files containing the types of brushes I want to use. Since I'm trying to keep only one brush per file, I end up importing all of the files at the top of each file in the following way:
var properties = require('./pathtofile');
var property1 = properties.property1;
var propert2 = properties.property2;
...
I'm trying to cut down on having lengthy lines with a lot of dots moving through hierarchy in them. Is there a better way to import multiple objects from another file either using browserify or another tool? I don't want these to be available globally but since there are a lot of properties it seems like a ton of repeated code.
Upvotes: 0
Views: 1075
Reputation: 3968
Is the object destructuring syntax the one you are looking for?
const { property1 , property2 } = require('./pathtofile')
Upvotes: 1