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

omitDeep changes input on empty array #111

Open emahuni opened 3 years ago

emahuni commented 3 years ago

There is an unexpected behavior with omitDeep, which I think is inherited throughout other parts of the lib as well. If omitDeep is given an empty array, it changes the array to null, which it should have left as an empty array. See code examples below.

let a = [{ aa: 'aaa', bb: { cc: 'ccc'}}]

_.omitDeep(a, 'cc')
// ==> [ { aa: 'aaa', bb: {} } ]  ✅

_.omitDeep([ [] ], 'cc')
// ==> [ [] ] ✅
_.omitDeep([], 'cc')
// ==> null ❌  <----  it was supposed to return [] like empty object below

_.omitDeep([{}], 'cc')
// ==> [ {} ] ✅
_.omitDeep({}, 'cc')
// ==> {} ✅  <--- empty object example
YuriGor commented 3 years ago

Hi, thank you for report, will check it soon