Skip to content
27 linesCodeBlameRaw

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 checks1const assert = require("node:assert");
2const math = require("./math");
Merge main into clamp branch3assert.strictEqual(math.subtract(5, 3), 2);
Add math helpers, tests and checks4
5assert.strictEqual(math.add(2, 3), 5);
Merge #3: Add multiply to math.js6assert.strictEqual(math.multiply(4, 5), 20);
Catch up with main7assert.strictEqual(math.divide(10, 4), 2.5);
8assert.throws(() => math.divide(1, 0), RangeError);
Add power function to math.js9assert.strictEqual(math.power(2, 10), 1024);
10assert.strictEqual(math.power(5, 0), 1);
11assert.throws(() => math.power(2, -1), RangeError);
Merge #21: Add tests for statistics functions in test.js12assert.strictEqual(math.mean([1, 2, 3]), 2);
Add mean, median, and standard_deviation to math.js13assert.strictEqual(math.mean([1, 2, 3, 4]), 2.5);
Merge #21: Add tests for statistics functions in test.js14assert.strictEqual(math.median([1, 2, 3]), 2);
Add mean, median, and standard_deviation to math.js15assert.strictEqual(math.median([3, 1, 2]), 2);
16assert.strictEqual(math.median([4, 1, 3, 2]), 2.5);
Merge #21: Add tests for statistics functions in test.js17assert.strictEqual(math.standard_deviation([1, 2, 3]), Math.sqrt(2 / 3));
Add mean, median, and standard_deviation to math.js18assert.strictEqual(math.standard_deviation([2, 4, 4, 4, 5, 5, 7, 9]), 2);
19for (const fn of [math.mean, math.median, math.standard_deviation]) {
20 assert.throws(() => fn([]), TypeError);
21}
Add clamp function to math.js22assert.strictEqual(math.clamp(5, 0, 10), 5);
23assert.strictEqual(math.clamp(-5, 0, 10), 0);
24assert.strictEqual(math.clamp(15, 0, 10), 10);
25assert.strictEqual(math.clamp(3, 3, 3), 3);
26assert.throws(() => math.clamp(1, 10, 0), RangeError);
Add math helpers, tests and checks27console.log("all tests passed");

This file's history is long; its oldest lines are credited to the oldest commit read.