Делаем просто:
const result = arr.reduce((acc, n, i, a) => (
(i && n.name === a[~-i].name) || acc.push([]),
acc.at(-1).push(n),
acc
), []);
Делаем сложно:
function groupAdjacent(
data,
{
key = n => n,
newGroup = (c, p) => c !== p,
} = {}
) {
const getVal = key instanceof Function ? key : n => n[key];
return Array.prototype.reduce.call(
data,
(acc, n, i) => {
const v = getVal(n, i);
const iGroup = acc[0].length - (i && !newGroup(v, acc[1]));
(acc[0][iGroup] ??= []).push(n);
acc[1] = v;
return acc;
},
[ [], null ]
)[0];
}
const result = groupAdjacent(arr, { newGroup: (c, p) => c.name !== p.name });
// или
const result = groupAdjacent(arr, { key: 'name' });