Is there a more elegant way to write this line of code?
_.chain(_.uniqBy(someArray,"someProperty.name")).map("someProperty").value();
it seems like I should be able to chain it, instead of nesting the lodash .uniqBy call inside of the .chain call.
I would expect the following to work, but it wont.
_.chain(someArray).map("someProperty").value().uniqBy("name");
The input is:
someArray = [
{
aProp: '1',
anotherProp: '2',
thirdProp: '3',
someProperty: {
id: 1,
name: "john"
}
},
{
aProp: '3',
anotherProp: '4',
thirdProp: '5',
someProperty: {
id: 1,
name: "john"
}
},
{
aProp: '2',
anotherProp: 'f',
thirdProp: '6',
someProperty: {
id: 2,
name: "tom"
}
},
{
aProp: 't',
anotherProp: 'g',
thirdProp: 'f',
someProperty: {
id: 3,
name: "yacob"
}
},
];
The output should be:
[{id:1, name:"john"},{id:2, name:"tom"},{id:3, name:"yacob"}]