Closed emahuni closed 3 years ago
this seem to be inherited in other places in the lib as well. Continuing the above example:
_.pickDeep(z, 'd')
// => { a: { d: [] } } ❌
// expected result similar to lodash pick
_.pick(z, 'a.d')
// => { a: { d: [ 'kk', 'jj' ] } } ✅
I was about to create an issue. I noticed that it does not work for Array as well
Hi all, this is as expected by default config: omit keeps parent if some children are not omitted.
To omit from the top as you expect try adding
_.omitDeep(z, 'b',{onMatch:{skipChildren:true}})
You can check docs: https://deepdash.io/#omitdeep
As you see in example - "bad2" is also not omitted, because there is "good" inside.
Any further feedback is welcome in this issue even after closing, if there will be enough votes about such defaults are confusing - I will consider to change defaults on next major version.
yes, I think the defaults are confusing... what I wrote as an issue is exactly what anyone would expect without reading and understanding anything. Then for those esoteric uses, one would adjust options. I already know how .omit works, so when I searched and found this lib, the assumption is that it should just behave like .omit out of the box (since it's ...dash as in lodash). The defaults are more opinionated I think.
I will try to use the config as indicated in the meantime, as I trust you will do the right thing 😅 in the next version.
oh my, it's working without the options added, wanted to have a false test first... did you already apply and publish the change? I recently installed it.
Hi, no changes yet.
I updated playground referenced by docs to illustrate skip children option I suggested above, so you can see before/after:
https://codepen.io/yurigor/pen/zQOMNj?editors=0010
You see in second case bad2/good was also omitted because of this option, but in first case it's still there.
The expected result is an omission of anything with the given key, but omitDeep seems to be omitting scalars only.
It's expected to work similarly to _.omit() as indicated above.