1var array = [{name:"foo1",value:"val1"},{name:"foo1",value:["val2","val3"]},{name:"foo2",value:"val4"}];
2
3function mergeNames (arr) {
4 return _.chain(arr).groupBy('name').mapValues(function (v) {
5 return _.chain(v).pluck('value').flattenDeep();
6 }).value();
7}
8
9console.log(mergeNames(array));
10