Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Add math helpers, tests and checks | 1 | // Small helpers for numbers. |
| Merge #3: Add multiply to math.js | 2 | /** Returns the sum of a and b. */ |
| Add math helpers, tests and checks | 3 | function add(a, b) { |
| 4 | return a + b; | |
| 5 | } | |
| 6 | ||
| Merge #3: Add multiply to math.js | 7 | /** Returns the product of a and b. */ |
| 8 | function multiply(a, b) { | |
| 9 | return a * b; | |
| 10 | } | |
| 11 | ||
| Add mod function to math.js | 12 | /** Returns the non-negative remainder of a divided by b; throws RangeError when b is 0. */ |
| 13 | function mod(a, b) { | |
| 14 | if (b === 0) { | |
| 15 | throw new RangeError("mod by zero"); | |
| 16 | } | |
| 17 | return ((a % b) + Math.abs(b)) % Math.abs(b); | |
| 18 | } | |
| 19 | ||
| 20 | module.exports = { add, multiply, mod }; |
This file's history is long; its oldest lines are credited to the oldest commit read.