Looks like you are very close!
There are several ways to do this.
IMO the cleanest way to do this is as follows:
import { map, reduce, somethingElse } from 'underscore'
Lets you call these methods like this:
map(things, thing => { ... })
The parameter '{map, reduce} = ...' is the destructive purpose of es6s. See the Mozilla docs page for more details.
Another way:
import map from 'underscore/map' import reduce from 'underscore/reduce'
Personally, I'm not a big fan of this, as it may start to be a little more cumbersome, as more methods get involved, but it has one slight advantage, you can name the link as you like:
import mappy from 'underscore/map' import reducerify from 'underscore/reduce'
Although I would not recommend using these names!
source share