deepdash icon indicating copy to clipboard operation
deepdash copied to clipboard

omitDeep changes input on empty array

Open emahuni opened this issue 4 years ago • 1 comments

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

emahuni avatar Jun 17 '21 09:06 emahuni

Hi, thank you for report, will check it soon

YuriGor avatar Jun 20 '21 21:06 YuriGor