Как из такого массива:
const arr = [
['user1',2001,1,100],['user1',2001,2,300],['user1',2001,3,300],['user1',2001,4,300],['user1',2002,1,300],
['user1',2002,2,500],['user1',2002,3,300],['user1',2002,4,300],['user1',2003,1,300],['user1',2003,2,100],
['user1',2003,3,300],['user1',2003,4,300],['user1',2004,1,100],['user2',2001,1,300],['user2',2001,2,300],
['user2',2001,3,300],['user2',2001,4,200],['user3',2001,1,300],['user3',2001,2,200],['user3',2001,3,300],
['user3',2001,4,400],['user3',2002,1,300],['user3',2002,2,300],['user3',2002,3,500]];
Получить такой объект:
const obj = [
{
user: 'user1',
data: [[2001,1,100],[2001,2,300],[2001,3,300],[2001,4,300],[2002,1,300],...]
},
{
user: 'user2',
data: [[2001,1,300],[2001,2,300],[2001,3,300],[2001,4,200],[2001,1,300],...]
},
{
user: 'user3',
data: [[2001,1,300],[2001,2,200],[2001,3,300],[2001,4,400],[2002,1,300],...]
}
];