Partial Lenses: Group array of objects by property, use prop value as key
问题 I have an array of objects like this: [ { name: "Group 1", value: "Foo" }, { name: "Group 2", value: "Bar" }, { name: "Group 1", value: "Baz" } ] I'd like to use Partial Lenses library to transform these groups to keys of an object with corresponding group's items, like this: { "Group 1": [ { name: "Group 1", value: "Foo" }, { name: "Group 1", value: "Baz" } ], "Group 2": [ { name: "Group 2", value: "Bar" } ] } My current approach is like this, assuming I have the source data in a variable