lolking0
lolking0
TTCTheo's Typesafe Cult
Created by lolking0 on 8/2/2023 in #questions
Possible to do in one loop?
thanks
14 replies
TTCTheo's Typesafe Cult
Created by lolking0 on 8/2/2023 in #questions
Possible to do in one loop?
okk
14 replies
TTCTheo's Typesafe Cult
Created by lolking0 on 8/2/2023 in #questions
Possible to do in one loop?
we already use it in the project
14 replies
TTCTheo's Typesafe Cult
Created by lolking0 on 8/2/2023 in #questions
Possible to do in one loop?
I'm using lodash so no worries
14 replies
TTCTheo's Typesafe Cult
Created by lolking0 on 8/2/2023 in #questions
Possible to do in one loop?
Thanks you're a god @nickserv
14 replies
TTCTheo's Typesafe Cult
Created by lolking0 on 8/2/2023 in #questions
Possible to do in one loop?
better way to do this?
14 replies
TTCTheo's Typesafe Cult
Created by lolking0 on 8/2/2023 in #questions
Possible to do in one loop?
came up with this rn
const 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');

const 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');

14 replies