Import some of a module's content as an object

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Import some of a module's content as an object

Baron Willeford
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:

```js
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:

```js
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:

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

Thanks,
Baron Willeford

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss