mathjs 14.5.3 → 14.7.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 (46) hide show
  1. package/HISTORY.md +21 -1
  2. package/lib/browser/math.js +1 -1
  3. package/lib/browser/math.js.LICENSE.txt +2 -2
  4. package/lib/browser/math.js.map +1 -1
  5. package/lib/cjs/core/function/config.js +0 -1
  6. package/lib/cjs/entry/dependenciesAny/dependenciesToBest.generated.js +17 -0
  7. package/lib/cjs/entry/dependenciesAny/dependenciesUnitClass.generated.js +2 -0
  8. package/lib/cjs/entry/dependenciesAny.generated.js +7 -0
  9. package/lib/cjs/entry/impureFunctionsAny.generated.js +1 -0
  10. package/lib/cjs/entry/pureFunctionsAny.generated.js +7 -3
  11. package/lib/cjs/expression/Parser.js +35 -1
  12. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +2 -0
  13. package/lib/cjs/expression/embeddedDocs/function/units/toBest.js +14 -0
  14. package/lib/cjs/expression/node/FunctionAssignmentNode.js +3 -1
  15. package/lib/cjs/expression/parse.js +1 -1
  16. package/lib/cjs/factoriesAny.js +7 -0
  17. package/lib/cjs/function/arithmetic/sign.js +1 -1
  18. package/lib/cjs/function/matrix/range.js +7 -5
  19. package/lib/cjs/function/unit/toBest.js +53 -0
  20. package/lib/cjs/header.js +2 -2
  21. package/lib/cjs/type/matrix/DenseMatrix.js +21 -17
  22. package/lib/cjs/type/string.js +4 -4
  23. package/lib/cjs/type/unit/Unit.js +106 -19
  24. package/lib/cjs/version.js +1 -1
  25. package/lib/esm/core/function/config.js +0 -1
  26. package/lib/esm/entry/dependenciesAny/dependenciesToBest.generated.js +10 -0
  27. package/lib/esm/entry/dependenciesAny/dependenciesUnitClass.generated.js +2 -0
  28. package/lib/esm/entry/dependenciesAny.generated.js +1 -0
  29. package/lib/esm/entry/impureFunctionsAny.generated.js +2 -1
  30. package/lib/esm/entry/pureFunctionsAny.generated.js +6 -2
  31. package/lib/esm/expression/Parser.js +35 -1
  32. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +2 -0
  33. package/lib/esm/expression/embeddedDocs/function/units/toBest.js +8 -0
  34. package/lib/esm/expression/node/FunctionAssignmentNode.js +3 -1
  35. package/lib/esm/expression/parse.js +1 -1
  36. package/lib/esm/factoriesAny.js +1 -0
  37. package/lib/esm/function/arithmetic/sign.js +1 -1
  38. package/lib/esm/function/matrix/range.js +7 -5
  39. package/lib/esm/function/unit/toBest.js +47 -0
  40. package/lib/esm/type/matrix/DenseMatrix.js +21 -17
  41. package/lib/esm/type/string.js +4 -4
  42. package/lib/esm/type/unit/Unit.js +106 -19
  43. package/lib/esm/version.js +1 -1
  44. package/package.json +15 -16
  45. package/types/index.d.ts +50 -1
  46. package/types/tslint.json +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "14.5.3",
3
+ "version": "14.7.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,33 +36,32 @@
36
36
  "typed-function": "^4.2.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.28.0",
39
+ "@babel/core": "7.28.3",
40
40
  "@babel/plugin-transform-object-assign": "7.27.1",
41
41
  "@babel/plugin-transform-optional-catch-binding": "7.27.1",
42
- "@babel/plugin-transform-runtime": "7.28.0",
43
- "@babel/preset-env": "7.28.0",
44
- "@babel/register": "7.27.1",
42
+ "@babel/plugin-transform-runtime": "7.28.3",
43
+ "@babel/preset-env": "7.28.3",
44
+ "@babel/register": "7.28.3",
45
45
  "@types/assert": "1.5.11",
46
46
  "@types/mocha": "10.0.10",
47
- "@typescript-eslint/eslint-plugin": "8.35.1",
48
- "@typescript-eslint/parser": "8.35.1",
47
+ "@typescript-eslint/eslint-plugin": "8.42.0",
48
+ "@typescript-eslint/parser": "8.42.0",
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.43.0",
54
53
  "del": "8.0.0",
55
- "dtslint": "4.2.1",
56
54
  "eigen": "0.2.2",
55
+ "es-check": "9.3.1",
57
56
  "eslint": "8.57.1",
58
57
  "eslint-config-prettier": "9.1.0",
59
58
  "eslint-config-standard": "17.1.0",
60
59
  "eslint-plugin-import": "2.32.0",
61
60
  "eslint-plugin-mocha": "10.5.0",
62
61
  "eslint-plugin-n": "16.6.2",
63
- "eslint-plugin-prettier": "5.5.1",
62
+ "eslint-plugin-prettier": "5.5.4",
64
63
  "eslint-plugin-promise": "6.6.0",
65
- "expect-type": "1.2.1",
64
+ "expect-type": "1.2.2",
66
65
  "expr-eval": "2.0.2",
67
66
  "fancy-log": "2.0.0",
68
67
  "glob": "11.0.3",
@@ -78,7 +77,7 @@
78
77
  "karma-webdriver-launcher": "1.0.8",
79
78
  "karma-webpack": "5.0.1",
80
79
  "mkdirp": "3.0.1",
81
- "mocha": "11.7.1",
80
+ "mocha": "11.7.2",
82
81
  "mocha-junit-reporter": "2.2.1",
83
82
  "ndarray": "1.0.19",
84
83
  "ndarray-determinant": "1.0.0",
@@ -90,10 +89,10 @@
90
89
  "process": "0.11.10",
91
90
  "sinon": "21.0.0",
92
91
  "sylvester": "0.0.21",
93
- "tinybench": "4.0.1",
92
+ "tinybench": "5.0.1",
94
93
  "ts-node": "10.9.2",
95
- "typescript": "5.8.3",
96
- "webpack": "5.99.9",
94
+ "typescript": "5.9.2",
95
+ "webpack": "5.101.3",
97
96
  "zeros": "1.0.0"
98
97
  },
99
98
  "type": "module",
@@ -149,7 +148,7 @@
149
148
  "test": "npm run test:src && npm run lint",
150
149
  "test:src": "mocha test/unit-tests",
151
150
  "test:generated": "mocha test/generated-code-tests",
152
- "test:node": "mocha test/node-tests/*.test.js test/node-tests/**/*.test.js",
151
+ "test:node": "mocha test/node-tests/*.test.{js,cjs,mjs} test/node-tests/**/*.test.{js,cjs,mjs}",
153
152
  "test:all": "npm run test:src && npm run test:generated && npm run test:node && npm run test:types",
154
153
  "test:browser": "karma start test/browser-test-config/local-karma.js",
155
154
  "test:lambdatest": "karma start test/browser-test-config/lambdatest-karma.js",
package/types/index.d.ts CHANGED
@@ -1904,6 +1904,14 @@ export interface MathJsInstance extends MathJsFactory {
1904
1904
  */
1905
1905
  det(x: MathCollection): number
1906
1906
 
1907
+ /**
1908
+ * Calculate the difference between adjacent elements of a matrix or array.
1909
+ * @param x A matrix or array
1910
+ * @param dim The dimension to apply the difference on.
1911
+ * @returns A matrix or array containing the differences
1912
+ */
1913
+ diff<T extends MathCollection>(x: T, dim?: number | BigNumber): T
1914
+
1907
1915
  /**
1908
1916
  * Create a diagonal matrix or retrieve the diagonal of a matrix. When x
1909
1917
  * is a vector, a matrix with vector x on the diagonal will be returned.
@@ -3488,6 +3496,18 @@ export interface MathJsInstance extends MathJsFactory {
3488
3496
  */
3489
3497
  to(x: Unit | MathCollection, unit: Unit | string): Unit | MathCollection
3490
3498
 
3499
+ /**
3500
+ * Converts a unit to the most appropriate display unit.
3501
+ * When no preferred units are provided, the function automatically find the best prefix.
3502
+ * When preferred units are provided, it converts to
3503
+ * the unit that gives a value closest to 1.
3504
+ * @param preferredUnits - Optional preferred target units
3505
+ * @param options - Optional options object
3506
+ * @returns Unit with optimized prefix/unit
3507
+ */
3508
+ toBest(): Unit
3509
+ toBest(units: string[] | Unit[], options: object): Unit
3510
+
3491
3511
  /*************************************************************************
3492
3512
  * Utils
3493
3513
  ************************************************************************/
@@ -3834,6 +3854,7 @@ export const {
3834
3854
  formatDependencies,
3835
3855
  printDependencies,
3836
3856
  toDependencies,
3857
+ toBestDependencies,
3837
3858
  isPrimeDependencies,
3838
3859
  numericDependencies,
3839
3860
  divideScalarDependencies,
@@ -4066,7 +4087,8 @@ export const {
4066
4087
  concatTransformDependencies,
4067
4088
  stdTransformDependencies,
4068
4089
  sumTransformDependencies,
4069
- varianceTransformDependencies
4090
+ varianceTransformDependencies,
4091
+ printTransformDependencies
4070
4092
  }: Record<string, FactoryFunctionMap>
4071
4093
 
4072
4094
  export interface Matrix<T = MathGeneric> {
@@ -4177,6 +4199,8 @@ export interface Unit {
4177
4199
  pow(unit: Unit): Unit
4178
4200
  abs(unit: Unit): Unit
4179
4201
  to(unit: string | Unit): Unit
4202
+ toBest(): Unit
4203
+ toBest(units?: string[] | Unit[], options?: object): Unit
4180
4204
  toNumber(unit?: string): number
4181
4205
  toNumeric(unit?: string): number | Fraction | BigNumber
4182
4206
  toSI(): Unit
@@ -5790,6 +5814,15 @@ export interface MathJsChain<TValue> {
5790
5814
  y: MathCollection
5791
5815
  ): MathJsChain<MathCollection>
5792
5816
 
5817
+ /**
5818
+ * Calculate the difference between adjacent elements of the chained matrix or array.
5819
+ * @param dim The dimension to apply the difference on.
5820
+ */
5821
+ diff<T extends MathCollection>(
5822
+ this: MathJsChain<T>,
5823
+ dim?: number | BigNumber
5824
+ ): MathJsChain<T>
5825
+
5793
5826
  /**
5794
5827
  * Calculate the determinant of a matrix.
5795
5828
  */
@@ -6991,6 +7024,21 @@ export interface MathJsChain<TValue> {
6991
7024
  unit: Unit | string
6992
7025
  ): MathJsChain<Unit | MathCollection>
6993
7026
 
7027
+ /**
7028
+ * Converts a unit to the most appropriate display unit.
7029
+ * When no preferred units are provided, the function automatically find the best prefix.
7030
+ * When preferred units are provided, it converts to
7031
+ * the unit that gives a value closest to 1.
7032
+ * @param preferredUnits - Optional preferred target units
7033
+ * @param options - Optional options object
7034
+ */
7035
+ toBest(this: MathJsChain<Unit>): MathJsChain<Unit>
7036
+ toBest(
7037
+ this: MathJsChain<Unit>,
7038
+ units: string[] | Unit[],
7039
+ options: object
7040
+ ): MathJsChain<Unit>
7041
+
6994
7042
  /*************************************************************************
6995
7043
  * Utils functions
6996
7044
  ************************************************************************/
@@ -7380,6 +7428,7 @@ export const {
7380
7428
 
7381
7429
  // unit functions
7382
7430
  to,
7431
+ toBest,
7383
7432
 
7384
7433
  // util functions
7385
7434
  isNumber,
package/types/tslint.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "dtslint/dtslint.json",
3
- "rules": {
4
- "no-redundant-jsdoc": false
5
- }
6
- }