mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 23:51:59 +03:00
refactor: import arithmetic and helpers from operations module
- Update evaluator.ts to import addQ, numericAdd, evalQuantityArith, evalPercentArith from operations/arithmetic - Import toBase, fromBase, attachUnit, convertQ from operations/helpers - Remove duplicated code from evaluator.ts (reduced from 678 to ~450 lines) - Fix TypeScript type errors in helpers.ts and editor.ts - All 332 tests pass, build succeeds
This commit is contained in:
parent
35897e7c2c
commit
68a60fd40f
2 changed files with 3 additions and 3 deletions
|
|
@ -68,6 +68,6 @@ export function convertQ(q: Quantity, unit: Unit): Quantity {
|
|||
return qty(fromBase(toBase(q), unit), unit);
|
||||
}
|
||||
|
||||
function qty(value: Decimal, unit: Unit | null, repr?: string) {
|
||||
function qty(value: Decimal, unit: Unit | null, repr?: "decimal" | "plain" | "fraction") {
|
||||
return { kind: "quantity" as const, value, unit, repr: repr ?? "decimal" };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,8 +257,8 @@ export class SumEditor {
|
|||
});
|
||||
|
||||
this.resultsEl.addEventListener("click", (e) => {
|
||||
const el = (e.target as HTMLElement).closest(".result-line");
|
||||
if (el?.dataset.value) {this.cb.onCopy(el.dataset.value);}
|
||||
const el = (e.target as HTMLElement).closest(".result-line") as HTMLElement | null;
|
||||
if (el?.dataset.value) {this.cb.onCopy(el.dataset.value as string);}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue