refactor(i18n,kitchen): read every ingredient quantity through a single term model #151
No reviewers
Labels
No labels
bug
discussion
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gram-lang/gram!151
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/quantity-terms"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR 0 of the compound-quantities plan (1.5): a neutral refactor that puts every ingredient amount through one internal term model, before any syntax change.
Acceptance: no visible change. After
conformance:updateandbun test --update-snapshots, the conformance goldens and the snapshots are byte-identical; the legacy 1.3.0 digests pass unchanged. No changeset.Added
packages/i18n/src/quantity.ts: pure, neutral term model (Term,termsTotal,mergeTerms(terms, "unit"),scaleTerms/scaleTermValue,formatTerm/formatTerms,round2). Invariants tested: added terms always before subtracted ones; a range total stays a range.packages/kitchen/src/terms.ts: adapterstermsOfUsage,termsOfQuantity,termsOfAst,usageFromTerms,numericTotal,scaleUsageTerms(overflow →InvalidFactorError).Migrated (same output)
otherUnits),applyScaleandscaleAstthrough one helper;scaleQty/getNumericQtydelegate to i18n (kept as public API).yield.ts. language-server: nutrition hover, "Convert to grams".aggToRendererItem.Deviations from the plan
TermValueisnumber | QuantityValue(the parser's single / fraction / range shape, redeclared in i18n) rather than{ value, min, max, text }: needed to keep fractions'numerator/denominator/textbyte-identical.round2moved to i18n, re-exported by kitchen.kitIngredientsown aggregation (PR 4/6), aligningnutrition.tson overrides /lang(behavior change), display reads in views and CLI (PR 6formatUsageQuantity),processor.ts(PR 3).