MCPcopy Create free account
hub / github.com/Packstack-Tech/packstack / getWeightByCategory

Function getWeightByCategory

frontend/src/lib/utils/weight.ts:71–81  ·  view source on GitHub ↗
(unit: WeightUnit, items: (PackItem | Item)[])

Source from the content-addressed store, hash-verified

69};
70
71export const getWeightByCategory = (unit: WeightUnit, items: (PackItem | Item)[]): CategoryItemSpecs[] => {
72 const itemsByCategory = getItemsByCategory(items);
73 return itemsByCategory.map((category, i) => {
74 const weightSpecs = getTotalWeight(unit, category.items);
75 return {
76 ...category,
77 ...weightSpecs,
78 color: colors[i]
79 }
80 }).sort((a, b) => b.total.value - a.total.value);
81};

Callers 3

PackItemsFunction · 0.90
ItemsFunction · 0.90
PackFunction · 0.90

Calls 2

getItemsByCategoryFunction · 0.90
getTotalWeightFunction · 0.85

Tested by

no test coverage detected