Lodash cloneDeepWith to omit undefined
I wrote a customozer function to omit the undefined values of the object with cloneDeepWith. However on the immutable return, it is not digging in recursively. Here is my code:
import { cloneDeepWith, pickBy, omit } from 'lodash';
const obj = {
a0: true,
b0: true,
c0: undefined,
obj1: {
a1: true,
b1: true,
c1: undefined
}
};
cloneDeepWith(obj, value => {
const objWithUndefinedValue = pickBy(obj, (value) => value === undefined);
const keysWithUndefinedValue = Object.keys(objWithUndefinedValue);
return omit(obj, keysWithUndefinedValue);
});
However it doesn't recurse after the first return. Is it possible to accomplish this with lodash stock functionality?