(items)
| 84 | const isPlainObject = (v) => v && typeof v === 'object' && !Array.isArray(v) |
| 85 | |
| 86 | const getArrayOrObject = (items) => { |
| 87 | if (items.length) { |
| 88 | const foundNonObject = items.find(o => !isPlainObject(o)) |
| 89 | // Non-objects and arrays cant be merged, so just return the first item |
| 90 | if (foundNonObject) { |
| 91 | return foundNonObject |
| 92 | } |
| 93 | // We use objects with 0,1,2,etc keys to merge array |
| 94 | if (items.every((o, i) => Object.hasOwn(o, i))) { |
| 95 | return Object.assign([], ...items) |
| 96 | } |
| 97 | } |
| 98 | // Otherwise its an object with all object items merged together |
| 99 | return Object.assign({}, ...items.filter(o => isPlainObject(o))) |
| 100 | } |
| 101 | |
| 102 | const redactValue = (obj) => JSON.parse(redactLog(JSON.stringify(obj))) |
| 103 |
no test coverage detected