let arr = [
{
key1: [1, 2, 3]
},
{
key2: [1, 2, 3]
},
{
key3: [4, 5, 6]
},
{
key3: [7, 8, 9]
},
{
key3: [10, 11, 12]
},
]
[
{
key1: [1, 2, 3]
},
{
key2: [1, 2, 3]
},
{
key3: [4, 5, 6, 7, 8, 9, 10, 11, 12]
}
]
Object.entries(arr.reduce((acc, n) => {
const [ k, v ] = Object.entries(n)[0];
(acc[k] = acc[k] || []).push(...v);
return acc;
}, {})).map(n => Object.fromEntries([ n ]))