What problem does it solve?
Centralizes sourdough calculation utilities to eliminate duplication across calculators and ensure consistent, maintainable results for the SourdoughSuite app.
Core Features & Use Cases
- Baker's Percentage Functions:
- calculateAmountFromPercentage(flourWeight, percentage)
- calculatePercentageFromAmount(ingredientWeight, flourWeight)
- Hydration Functions:
- calculateHydrationPercent(waterWeight, flourWeight)
- calculateWaterNeeded(waterWeight, targetHydration)
- calculateFlourNeeded(waterWeight, targetHydration)
- Scaling Functions:
- calculateScaleFactor(original, target)
- scaleAmount(amount, scaleFactor)
- Starter/Preferment Functions:
- decomposeLevain(totalLevainWeight, hydration)
- calculateStarterPercentage(starterFlour, totalFlour)
- calculatePrefermentFlour(totalFlour, prefermentPercent)
- Dough Weight Functions:
- calculatePreBakeWeight(postBakeWeight, bakingLossPercent)
- calculateWeightLoss(preBakeWeight, postBakeWeight)
- calculateWeightLossPercent(preBakeWeight, postBakeWeight)
- Temperature Functions:
- calculateWaterTemperature(targetDDT, roomTemp, flourTemp, starterTemp, frictionFactor)
- Utility Functions:
- roundTo(value, decimals = 1)
- formatWeight(grams, decimals = 0)
- formatPercent(percent, decimals = 1)
- validatePositiveNumber(value, fieldName)
- validatePercentage(value, fieldName)
Quick Start
Use the sourdough-formulas library to perform core calculations by importing from src/utils/sourdoughCalculations.ts, then call the desired functions (e.g., calculateAmountFromPercentage, formatWeight) in your calculator screens or tests.