jfmengels / lodash-codemods

Codemods to simplify upgrading Lodash versions
MIT License
33 stars 8 forks source link

3.x _.sum(array) should be converted to 4.x _.sumBy(array, Number) #11

Open ameliabradley opened 7 years ago

ameliabradley commented 7 years ago

The Lodash 4.0 _.sum implementation no longer casts elements to Number.

Implications: Lodash 3.0 _.sum([20, 3, "10"]) = 33 Lodash 4.0 _.sum([20, 3, "10"]) = "20310"

In my case, this change led to some very wrong graphs 😅

lodash-codemods should play it safe, and make this translation: _.sum([0, 3, "10"]) -> _.sumBy([0, 3, "10"], Number)