Interesting way with Lodash

As a Javascript developer, there are a few common libraries that we depend on to help speed up our development. For one, Lodash is something that I can’t live without. It helps my code to be readable, and not to keep on reinventing common functions that can just plug and play.

I came across this interesting article about Lodash (Why using chain is a mistake), and it makes me rethink about how I have been using not just Lodash but other libraries that as well. Regardless, this is something that may change how I use the library in the future, but is still a little too much of a hassle and making simple things complicated when we want to bootstrap certain project up to speed.

For simple Lodash function, I might still opt to use the cheap way for it to load faster. In the case where even every 100kb counts. Such as a website landing page.

import chain from "lodash/chain";
import value from "lodash/value";
import map from "lodash/map";
import mixin from "lodash/mixin";
import _ from "lodash/wrapperLodash";
// Add the methods you want. The object generated by chain() will
// now have these methods.

mixin(_, {map: map, chain: chain, value: value});
_.chain([1,2,3]).map(x => x+1).value(); // Use the methods.

Of course, in the article, it also talks about “Currying”, and provide with some practical example to give you actual usage how to use that. In my years of development, I have not really built things that depend on “curry”, since javascript is so flexible that I can even live without it.