YuriGor / deepdash

eachDeep, filterDeep, findDeep, someDeep, omitDeep, pickDeep, keysDeep etc.. Tree traversal library written in Underscore/Lodash fashion
https://deepdash.io/
MIT License
272 stars 12 forks source link

filterDeep return undefined if no children found #83

Closed ferreirix closed 3 years ago

ferreirix commented 3 years ago

Is it possible to have children as undefined if no children respects the predicate?

For instance, in this example, can the second object in the array have children as undefined instead of empty array?

{
    "name": "2",
    "bad": true,
    "children": undefined
}

vs

{
    "name": "2",
    "bad": true,
    "children": []
}

Thank you in advance for your help.

YuriGor commented 3 years ago

Hi, no such option exists.

You can do second filtering like this: https://codepen.io/yurigor/pen/QWKqBRR?editors=0010

It would be nice to have such option so maybe I will add it, once I will have some time for this.