mathjs 14.4.0 → 14.5.0

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.
Files changed (40) hide show
  1. package/HISTORY.md +11 -0
  2. package/README.md +1 -1
  3. package/lib/browser/math.js +1 -1
  4. package/lib/browser/math.js.LICENSE.txt +2 -2
  5. package/lib/browser/math.js.map +1 -1
  6. package/lib/cjs/constants.js +12 -12
  7. package/lib/cjs/core/create.js +1 -2
  8. package/lib/cjs/defaultInstance.js +1 -2
  9. package/lib/cjs/entry/allFactoriesAny.js +1 -2
  10. package/lib/cjs/entry/allFactoriesNumber.js +1 -2
  11. package/lib/cjs/expression/embeddedDocs/construction/index.js +1 -1
  12. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -0
  13. package/lib/cjs/expression/embeddedDocs/function/expression/compile.js +14 -0
  14. package/lib/cjs/expression/embeddedDocs/function/expression/evaluate.js +1 -1
  15. package/lib/cjs/expression/embeddedDocs/function/expression/parse.js +14 -0
  16. package/lib/cjs/expression/embeddedDocs/function/expression/parser.js +14 -0
  17. package/lib/cjs/expression/embeddedDocs/function/statistics/sum.js +1 -1
  18. package/lib/cjs/expression/function/parser.js +1 -1
  19. package/lib/cjs/expression/parse.js +3 -2
  20. package/lib/cjs/function/arithmetic/add.js +33 -33
  21. package/lib/cjs/header.js +2 -2
  22. package/lib/cjs/type/matrix/DenseMatrix.js +127 -91
  23. package/lib/cjs/type/unit/Unit.js +19 -4
  24. package/lib/cjs/utils/snapshot.js +1 -2
  25. package/lib/cjs/version.js +1 -1
  26. package/lib/esm/constants.js +12 -12
  27. package/lib/esm/expression/embeddedDocs/construction/index.js +1 -1
  28. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
  29. package/lib/esm/expression/embeddedDocs/function/expression/compile.js +8 -0
  30. package/lib/esm/expression/embeddedDocs/function/expression/evaluate.js +1 -1
  31. package/lib/esm/expression/embeddedDocs/function/expression/parse.js +8 -0
  32. package/lib/esm/expression/embeddedDocs/function/expression/parser.js +8 -0
  33. package/lib/esm/expression/embeddedDocs/function/statistics/sum.js +1 -1
  34. package/lib/esm/expression/function/parser.js +1 -1
  35. package/lib/esm/expression/parse.js +3 -2
  36. package/lib/esm/function/arithmetic/add.js +33 -33
  37. package/lib/esm/type/matrix/DenseMatrix.js +133 -97
  38. package/lib/esm/type/unit/Unit.js +19 -4
  39. package/lib/esm/version.js +1 -1
  40. package/package.json +17 -17
@@ -618,8 +618,8 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
618
618
 
619
619
  // If at least one operand has a value, then the result should also have a value
620
620
  if (this.value !== null || other.value !== null) {
621
- var valThis = this.value === null ? this._normalize(1) : this.value;
622
- var valOther = other.value === null ? other._normalize(1) : other.value;
621
+ var valThis = this.value === null ? this._normalize(one(other.value)) : this.value;
622
+ var valOther = other.value === null ? other._normalize(one(this.value)) : other.value;
623
623
  res.value = multiplyScalar(valThis, valOther);
624
624
  } else {
625
625
  res.value = null;
@@ -666,8 +666,8 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
666
666
 
667
667
  // If at least one operand has a value, the result should have a value
668
668
  if (this.value !== null || other.value !== null) {
669
- var valThis = this.value === null ? this._normalize(1) : this.value;
670
- var valOther = other.value === null ? other._normalize(1) : other.value;
669
+ var valThis = this.value === null ? this._normalize(one(other.value)) : this.value;
670
+ var valOther = other.value === null ? other._normalize(one(this.value)) : other.value;
671
671
  res.value = divideScalar(valThis, valOther);
672
672
  } else {
673
673
  res.value = null;
@@ -723,6 +723,21 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
723
723
  }
724
724
  }
725
725
 
726
+ /**
727
+ * Create a value one with the numeric type of `typeOfValue`.
728
+ * For example, `one(new BigNumber(3))` returns `BigNumber(1)`
729
+ * @param {number | Fraction | BigNumber} typeOfValue
730
+ * @returns {number | Fraction | BigNumber}
731
+ */
732
+ function one(typeOfValue) {
733
+ // TODO: this is a workaround to prevent the following BigNumber conversion error from throwing:
734
+ // "TypeError: Cannot implicitly convert a number with >15 significant digits to BigNumber"
735
+ // see https://github.com/josdejong/mathjs/issues/3450
736
+ // https://github.com/josdejong/mathjs/pull/3375
737
+ var convert = Unit._getNumberConverter(typeOf(typeOfValue));
738
+ return convert(1);
739
+ }
740
+
726
741
  /**
727
742
  * Calculate the absolute value of a unit
728
743
  * @memberof Unit
@@ -1,3 +1,3 @@
1
- export var version = '14.4.0';
1
+ export var version = '14.5.0';
2
2
  // Note: This file is automatically generated when building math.js.
3
3
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "14.4.0",
3
+ "version": "14.5.0",
4
4
  "description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
5
5
  "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
6
6
  "homepage": "https://mathjs.org",
@@ -36,21 +36,21 @@
36
36
  "typed-function": "^4.2.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.26.10",
40
- "@babel/plugin-transform-object-assign": "7.25.9",
41
- "@babel/plugin-transform-optional-catch-binding": "7.25.9",
42
- "@babel/plugin-transform-runtime": "7.26.10",
43
- "@babel/preset-env": "7.26.9",
44
- "@babel/register": "7.25.9",
39
+ "@babel/core": "7.27.1",
40
+ "@babel/plugin-transform-object-assign": "7.27.1",
41
+ "@babel/plugin-transform-optional-catch-binding": "7.27.1",
42
+ "@babel/plugin-transform-runtime": "7.27.1",
43
+ "@babel/preset-env": "7.27.2",
44
+ "@babel/register": "7.27.1",
45
45
  "@types/assert": "1.5.11",
46
46
  "@types/mocha": "10.0.10",
47
- "@typescript-eslint/eslint-plugin": "8.27.0",
48
- "@typescript-eslint/parser": "8.27.0",
47
+ "@typescript-eslint/eslint-plugin": "8.32.1",
48
+ "@typescript-eslint/parser": "8.32.1",
49
49
  "assert": "2.1.0",
50
50
  "babel-loader": "10.0.0",
51
51
  "c8": "10.1.3",
52
52
  "codecov": "3.8.3",
53
- "core-js": "3.41.0",
53
+ "core-js": "3.42.0",
54
54
  "del": "8.0.0",
55
55
  "dtslint": "4.2.1",
56
56
  "eigen": "0.2.2",
@@ -60,12 +60,12 @@
60
60
  "eslint-plugin-import": "2.31.0",
61
61
  "eslint-plugin-mocha": "10.5.0",
62
62
  "eslint-plugin-n": "16.6.2",
63
- "eslint-plugin-prettier": "5.2.4",
63
+ "eslint-plugin-prettier": "5.4.0",
64
64
  "eslint-plugin-promise": "6.6.0",
65
- "expect-type": "1.2.0",
65
+ "expect-type": "1.2.1",
66
66
  "expr-eval": "2.0.2",
67
67
  "fancy-log": "2.0.0",
68
- "glob": "11.0.1",
68
+ "glob": "11.0.2",
69
69
  "gulp": "5.0.0",
70
70
  "gulp-babel": "8.0.0",
71
71
  "handlebars": "4.7.8",
@@ -78,7 +78,7 @@
78
78
  "karma-webdriver-launcher": "1.0.8",
79
79
  "karma-webpack": "5.0.1",
80
80
  "mkdirp": "3.0.1",
81
- "mocha": "11.1.0",
81
+ "mocha": "11.4.0",
82
82
  "mocha-junit-reporter": "2.2.1",
83
83
  "ndarray": "1.0.19",
84
84
  "ndarray-determinant": "1.0.0",
@@ -88,12 +88,12 @@
88
88
  "numericjs": "1.2.6",
89
89
  "prettier": "3.5.3",
90
90
  "process": "0.11.10",
91
- "sinon": "19.0.4",
91
+ "sinon": "20.0.0",
92
92
  "sylvester": "0.0.21",
93
93
  "tinybench": "4.0.1",
94
94
  "ts-node": "10.9.2",
95
- "typescript": "5.8.2",
96
- "webpack": "5.98.0",
95
+ "typescript": "5.8.3",
96
+ "webpack": "5.99.9",
97
97
  "zeros": "1.0.0"
98
98
  },
99
99
  "type": "module",