Import some of a module's content as an object

Baron Willeford baron.willeford at gmail.com
Sun Sep 10 20:27:04 UTC 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170910/0814540a/attachment.html>


More information about the es-discuss mailing list