document-compute.js 1.5.4 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -12,16 +12,12 @@ function toRational(value) {
12
12
  }
13
13
  function gcd(a, b) {
14
14
  let x = a < 0n ? -a : a;
15
- let y = b < 0n ? -b : b;
15
+ let y = b;
16
16
  while (y !== 0n) [x, y] = [y, x % y];
17
- return x === 0n ? 1n : x;
17
+ return x;
18
18
  }
19
19
  function reduce(n, d) {
20
20
  if (d === 0n) throw new RangeError("rational.ts: denominator must not be zero");
21
- if (n === 0n) return {
22
- n: 0n,
23
- d: 1n
24
- };
25
21
  const sign = d < 0n ? -1n : 1n;
26
22
  const num = n * sign;
27
23
  const den = d * sign;
@@ -642,14 +638,12 @@ function sumBy(items, project) {
642
638
  }
643
639
  function formatOutcome(outcome) {
644
640
  switch (outcome.outcome) {
645
- case "match": return `match: ${outcome.targetSymbol}`;
646
641
  case "mismatch": return `MISMATCH: ${outcome.targetSymbol} -- expected ${formatEvaluationResult(outcome.expected)}, got ${formatEvaluationResult(outcome.actual)}`;
647
642
  case "gap": return `GAP (${outcome.gap}): ${outcome.targetSymbol} -- ${outcome.message}`;
648
643
  case "unresolved": return `unresolved: ${outcome.targetSymbol} -- ${outcome.message}`;
649
644
  }
650
645
  }
651
646
  function formatEvaluationResult(value) {
652
- if (value.kind === "interval") return `[${value.min}, ${value.max}]`;
653
647
  return `${value.magnitude}`;
654
648
  }
655
649
  function formatCorpusReport(report) {
package/dist/index.js CHANGED
@@ -11,16 +11,12 @@ function toRational(value) {
11
11
  }
12
12
  function gcd(a, b) {
13
13
  let x = a < 0n ? -a : a;
14
- let y = b < 0n ? -b : b;
14
+ let y = b;
15
15
  while (y !== 0n) [x, y] = [y, x % y];
16
- return x === 0n ? 1n : x;
16
+ return x;
17
17
  }
18
18
  function reduce(n, d) {
19
19
  if (d === 0n) throw new RangeError("rational.ts: denominator must not be zero");
20
- if (n === 0n) return {
21
- n: 0n,
22
- d: 1n
23
- };
24
20
  const sign = d < 0n ? -1n : 1n;
25
21
  const num = n * sign;
26
22
  const den = d * sign;
@@ -641,14 +637,12 @@ function sumBy(items, project) {
641
637
  }
642
638
  function formatOutcome(outcome) {
643
639
  switch (outcome.outcome) {
644
- case "match": return `match: ${outcome.targetSymbol}`;
645
640
  case "mismatch": return `MISMATCH: ${outcome.targetSymbol} -- expected ${formatEvaluationResult(outcome.expected)}, got ${formatEvaluationResult(outcome.actual)}`;
646
641
  case "gap": return `GAP (${outcome.gap}): ${outcome.targetSymbol} -- ${outcome.message}`;
647
642
  case "unresolved": return `unresolved: ${outcome.targetSymbol} -- ${outcome.message}`;
648
643
  }
649
644
  }
650
645
  function formatEvaluationResult(value) {
651
- if (value.kind === "interval") return `[${value.min}, ${value.max}]`;
652
646
  return `${value.magnitude}`;
653
647
  }
654
648
  function formatCorpusReport(report) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-compute.js",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "Units-typed, tree-walking evaluator for document-schema.js's MathExpression -- exact-rational unit conversion, interval arithmetic, and bisection/Newton numeric solve-for, the compute package for the documents.js family.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -79,7 +79,7 @@
79
79
  "@stryker-mutator/typescript-checker": "10.0.0",
80
80
  "@stryker-mutator/vitest-runner": "10.0.0",
81
81
  "@types/node": "26.2.0",
82
- "documents.js": "7.20.2",
82
+ "documents.js": "7.20.3",
83
83
  "eslint": "10.8.1",
84
84
  "husky": "9.1.7",
85
85
  "markdown-codec": "6.7.1",