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.
There's another alternative using DeepDash, which is a standalone, complementary library that offers recursive versions of Lodash functions.
Once DeepDash has been mixed in with Lodash (deepdash(_)
), you can write a prune
function like this:
const prune = obj => _.filterDeep(obj, (v) => !_.isUndefined(v))