Partition cart lines into delivery groups
Group cart lines by normalized delivery key while preserving line order and calculating integer quantity totals.Description
Requirements
Export partitionDeliveryGroups from src/App.js.
Use trimmed deliveryKey values and route empty keys to unassigned.
Keep lines in their original order within each delivery group.
Sum positive integer quantities for each group.
Return groups in first-seen delivery-key order.
Return an observably equivalent result for equivalent inputs without reading time, randomness, network, storage, or DOM globals.
Do not mutate input objects, arrays, nested records, or values retained in the returned result.
Two shipments
home, pickup, then home lines
Groups are home then pickup; home retains both lines
Use trimmed deliveryKey values and route empty keys to unassigned.
Missing key
A line has a blank delivery key
It belongs to unassigned
Keep lines in their original order within each delivery group.
Constraints
Implement a pure synchronous function with no external side effectsTreat every input collection and nested record as read-onlyReturn JSON-compatible data except where the declared TypeScript API explicitly uses bigint
Hints
Hint 1
Start with the normalizes-group-key behavior and make its observable result deterministic.
Hint 2
Model preserves-line-order independently before combining it with the remaining states.
Hint 3
Verify the boundary described by orders-groups without changing caller-owned input.