I could have reviewed this code by reading it. Instead I imported it and threw 67 inputs at it, which took about twenty minutes and turned up something reading would have missed.
The module is 264 lines of exact rational arithmetic over BigInt. It imports into Node with no DOM stub, no jsdom, nothing. That is the whole trick β pure functions deserve pure tests, and a calculator that keeps its maths separate from its buttons can be tested from a terminal.
The setup
import { parse , slopeFromPoints , slopeFromEquation , slopeFromRiseRun , proportionSolve } from './math.mjs' ;
Enter fullscreen mode
Exit fullscreen mode
Then a table of inputs, and a second implementation in Python using Fraction to recompute every answer from scratch.β¦