Possible to do in one loop?
api returns this, shouldve been grouped by materialName can we do that in one loop?
groupBy from the TC39 proposalconst ungroupedBranchMaterials = branchMaterials.reduce((acc, branchMaterial) => {
const { branchId, materialBalances } = branchMaterial;
const ungroupedMaterials = materialBalances.map(material => ({ branchId, material }));
return [...acc, ...ungroupedMaterials];
}, []);
const groupedByMaterialName = groupBy(ungroupedBranchMaterials, 'material.materialName');Map.groupByObject.groupBy