'Group by a set of JavaScript Objects [duplicate]

I've got this set of data :

  { CIRPIC: 'AUA', ALLPIC: 2 },
  { CIRPIC: 'AUA', ALLPIC: 3 },
  { CIRPIC: 'AUA', ALLPIC: 1 },
  { CIRPIC: 'AUA', ALLPIC: 4 },
  { CIRPIC: 'AUF', ALLPIC: 12 },
  { CIRPIC: 'AU3', ALLPIC: 2 },
  { CIRPIC: 'AU3', ALLPIC: 7 },

And I would like it to be like this :

{CIRPIC: 'AUA', ALLPIC: [2,3,1,4]},
{CIRPIC: 'AUF', ALLPIC: [12]},
{CIRPIC: 'AU3', ALLPIC: [2,7]},

Thanks for your help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source