Lodash cloneDeepWith to omit undefined

后端 未结 3 1198
你的背包
你的背包 2021-01-05 10:19

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.

3条回答
  •  孤城傲影
    2021-01-05 11:05

    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))
    

提交回复
热议问题