Giter Site home page Giter Site logo

omitDeep doesn't omit objects about deepdash HOT 7 CLOSED

emahuni avatar emahuni commented on June 10, 2024
omitDeep doesn't omit objects

from deepdash.

Comments (7)

emahuni avatar emahuni commented on June 10, 2024

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' ] } } ✅

from deepdash.

Instrumedley avatar Instrumedley commented on June 10, 2024

I was about to create an issue. I noticed that it does not work for Array as well

from deepdash.

YuriGor avatar YuriGor commented on June 10, 2024

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.

from deepdash.

emahuni avatar emahuni commented on June 10, 2024

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.

from deepdash.

emahuni avatar emahuni commented on June 10, 2024

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.

from deepdash.

emahuni avatar emahuni commented on June 10, 2024

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.

from deepdash.

YuriGor avatar YuriGor commented on June 10, 2024

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
image
You see in second case bad2/good was also omitted because of this option, but in first case it's still there.

from deepdash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.