The roastery’s batch planner now runs in JavaScript. For tonight’s paste of "37.5", batch-plan.js prints the same four lines as batch_plan.py. The two scripts also agree on the blank paste and "1_200".
You can now:
- Use
Numberfor the planner’s ordinary whole and decimal values, and askNumber.isInteger()whether the stored value is whole - Guard against division by zero, which raises an error in Python but gives
NaN,Infinity, or-Infinityin JavaScript - Use
Math.floor(a / b)for the planner’s//calculation andMath.trunc()forint()on finite numbers, pairingMath.floor()with((a % n) + n) % nandMath.trunc()with% - Round with
Math.ceil()andMath.round(x * 100) / 100 - Convert text with
Number(), treat blank text as missing, and check forNaNwithNumber.isNaN() - Read a number off the front of text such as
"17.5kg"withparseFloat() - Format numbers last with
.toFixed()andIntl.NumberFormat, naming the locale
Most of that came from knowing which Python habits to keep and which to drop.