Import some of a module's content as an object

# Baron Willeford (7 years ago)

When I want to import some values from a another module, but want to keep those values in an object, I either have to import everything and pack it back up into another object, as so:

import * as myModule from './myModule';

var new_obj = {
  item1: myModule.item1,
  item3: myModule.item3,
  item6: myModule.item6
};

Or I have to import just what I want, and then again pack it into a new object:

import {
  item1,
  item3,
  item6
} from './myModule';

var new_obj = {
  item1,
  item3,
  item6
};

I request that JS allow importing just the values I want directly into a new object:

import {
  item1,
  item3,
  item6
} as new_obj from './myModule';

Thanks, Baron Willeford