filterDeep remove functions when use for omiting #94
Replies: 4 comments
-
Hi, by default filterDeep uses Lodash cloneDeep internally, and cloneDeep doesn't support functions (because it's impossible to make good assumption in case of functions, how to clone them) You can provide your own cloning method, check docs here: So instead of default clone method you can create your own, using, for example, cloneDeepWith from Lodash and handle the case of function values as you would like to. |
Beta Was this translation helpful? Give feedback.
-
I don't understand exactly. My omitByDeep solution also use _,cloneDeep and handle the functions as well. |
Beta Was this translation helpful? Give feedback.
-
Yeah, that's weird, In the case of filterDeep - it doesn't clone the whole source object, so functions inside the object, while being cloned, are not deep, so they returned as empty objects, as expected according to Lodash docs. BTW here is a fork of your codepen with filterDeep example keeping functions: |
Beta Was this translation helpful? Give feedback.
-
Thanx for the pen. |
Beta Was this translation helpful? Give feedback.
-
filterDeep convert type function (for example: String) to empty object.
You can check this pen: https://codepen.io/gabortorma/pen/OJyBWXP
You can see on the console. omitByDeep keep the function, filterDeep convert it to empty object.
Beta Was this translation helpful? Give feedback.
All reactions