YuriGor / deepdash

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

keepIfEmpty not working as explained for filterDeep #43

Closed aariacarterweir closed 3 years ago

aariacarterweir commented 4 years ago

Could just be how I've interpreted it, but:

_.filterDeep(arr, Boolean, { leavesOnly: true, onFalse: { keepIfEmpty: true } })

still removes empty objects

YuriGor commented 4 years ago

Hi, could you also provide sample data? If you have initially empty object as a value it's treated as a leaf also, so maybe it's filtered out as not a boolean.

YuriGor commented 4 years ago

No response, closing for now.

aariacarterweir commented 4 years ago

Sorry for not replying sooner, I found that this did what I needed it to do:

_.filterDeep(data, Boolean, { leavesOnly: true, onUndefined: { keepIfEmpty: true } })

YuriGor commented 4 years ago

Cool, welcome back if anything