When homeowners plan a weekend landscaping or fencing project in the US, the hardest part is rarely digging—it is ordering the right amount of material without paying for a second delivery truck.
Most online estimators either oversimplify the geometry or bury the actual math behind cluttered forms. While building Easy Yard Calculator , I ran into two subtle domain details that make a surprisingly big difference in TypeScript calculation accuracy.
1. Converting Mixed Imperial Units Cleanly
US landscaping quotes mix three units in a single job: length and width in feet , depth in inches , and bulk supplier pricing in cubic yards or tons . Keeping the pure calculation function stateless makes unit testing straightforward:
export interface AreaCalcInput { lengthFt : number ; widthFt : number ; depthIn : number ; wastePct : number ; tonsPerCubicYard : number ; pricePerCubicYard : number ; }
export function calculateAreaMaterial ( input : AreaCalcInput ) { const depthFt = Math . max ( 0 , input .…