Reputation: 34677
I have a code like this:
const _ = require('lodash');
const fn = _.partialRight(_.pick, _.identity);
const x = { some: 'value', empty: null };
const y = fn(x);
console.log('x:', x);
console.log('y:', y);
fn
is supposed to remove empty properties
Result with Lodash 3.10.1:
x: { some: 'value', empty: null }
y: { some: 'value' }
Result with Lodash 4.15.0:
x: { some: 'value', empty: null }
y: {}
What has changed in Lodash 4 that it's not working anymore?
Upvotes: 2
Views: 520
Reputation: 2153
Updating from 3.10.1 to 4.17.21
The functions I have needed to update so far are:
_contains to _.includes
_.pluck to _.map
_.findWhere to _.find
_.first to ._head
_.object to _.fromPairs
Upvotes: 1
Reputation: 6980
change your const fn = _.partialRight(_.pick, _.identity)
to
const fn = _.partialRight(_.pickBy, _.identity);
_.pick
used to be just one function but they broke it out into _.pick
and _.pickBy
in the latest updates. you would use _.pick
when you are passing in known keys and _.pickBy
when you are using a custom function to test if a key/value should be picked based on your own parameters,
https://lodash.com/docs/4.15.0#pick
https://lodash.com/docs/4.15.0#pickBy
Upvotes: 1