mathjs 12.4.1 → 12.4.3

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 (67) hide show
  1. package/HISTORY.md +17 -0
  2. package/README.md +4 -0
  3. package/bin/cli.js +1 -1
  4. package/lib/browser/math.js +1 -1
  5. package/lib/browser/math.js.LICENSE.txt +2 -2
  6. package/lib/browser/math.js.map +1 -1
  7. package/lib/cjs/core/create.js +3 -3
  8. package/lib/cjs/core/function/config.js +1 -11
  9. package/lib/cjs/core/function/import.js +3 -4
  10. package/lib/cjs/defaultInstance.js +1 -1
  11. package/lib/cjs/entry/allFactoriesAny.js +1 -1
  12. package/lib/cjs/entry/allFactoriesNumber.js +1 -1
  13. package/lib/cjs/expression/node/AccessorNode.js +2 -3
  14. package/lib/cjs/expression/node/ArrayNode.js +2 -3
  15. package/lib/cjs/expression/node/AssignmentNode.js +2 -3
  16. package/lib/cjs/expression/node/BlockNode.js +2 -3
  17. package/lib/cjs/expression/node/ConditionalNode.js +2 -3
  18. package/lib/cjs/expression/node/ConstantNode.js +2 -3
  19. package/lib/cjs/expression/node/FunctionAssignmentNode.js +2 -3
  20. package/lib/cjs/expression/node/FunctionNode.js +5 -6
  21. package/lib/cjs/expression/node/IndexNode.js +2 -3
  22. package/lib/cjs/expression/node/Node.js +1 -2
  23. package/lib/cjs/expression/node/ObjectNode.js +2 -3
  24. package/lib/cjs/expression/node/OperatorNode.js +2 -3
  25. package/lib/cjs/expression/node/ParenthesisNode.js +2 -3
  26. package/lib/cjs/expression/node/RangeNode.js +2 -3
  27. package/lib/cjs/expression/node/RelationalNode.js +2 -3
  28. package/lib/cjs/expression/node/SymbolNode.js +2 -3
  29. package/lib/cjs/expression/parse.js +7 -7
  30. package/lib/cjs/function/algebra/derivative.js +1 -1
  31. package/lib/cjs/function/algebra/rationalize.js +2 -2
  32. package/lib/cjs/function/algebra/simplifyConstant.js +1 -1
  33. package/lib/cjs/function/statistics/mad.js +1 -1
  34. package/lib/cjs/function/statistics/std.js +1 -1
  35. package/lib/cjs/function/statistics/utils/improveErrorMessage.js +2 -2
  36. package/lib/cjs/function/utils/isNaN.js +5 -3
  37. package/lib/cjs/header.js +2 -2
  38. package/lib/cjs/type/unit/Unit.js +3 -2
  39. package/lib/cjs/utils/array.js +0 -11
  40. package/lib/cjs/utils/bignumber/formatter.js +1 -1
  41. package/lib/cjs/utils/factory.js +1 -2
  42. package/lib/cjs/utils/map.js +2 -4
  43. package/lib/cjs/utils/object.js +1 -7
  44. package/lib/cjs/utils/snapshot.js +5 -5
  45. package/lib/cjs/version.js +1 -1
  46. package/lib/esm/core/create.js +3 -3
  47. package/lib/esm/core/function/config.js +1 -11
  48. package/lib/esm/core/function/import.js +3 -4
  49. package/lib/esm/expression/node/FunctionNode.js +3 -3
  50. package/lib/esm/expression/parse.js +7 -7
  51. package/lib/esm/function/algebra/derivative.js +1 -1
  52. package/lib/esm/function/algebra/rationalize.js +2 -2
  53. package/lib/esm/function/algebra/simplifyConstant.js +1 -1
  54. package/lib/esm/function/statistics/mad.js +1 -1
  55. package/lib/esm/function/statistics/std.js +1 -1
  56. package/lib/esm/function/statistics/utils/improveErrorMessage.js +2 -2
  57. package/lib/esm/function/utils/isNaN.js +1 -3
  58. package/lib/esm/type/unit/Unit.js +3 -2
  59. package/lib/esm/utils/array.js +0 -10
  60. package/lib/esm/utils/bignumber/formatter.js +1 -1
  61. package/lib/esm/utils/factory.js +1 -2
  62. package/lib/esm/utils/object.js +1 -4
  63. package/lib/esm/utils/snapshot.js +4 -4
  64. package/lib/esm/version.js +1 -1
  65. package/package.json +15 -15
  66. package/types/EXPLANATION.md +13 -1
  67. package/types/index.d.ts +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "12.4.1",
3
+ "version": "12.4.3",
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",
@@ -25,7 +25,7 @@
25
25
  "unit"
26
26
  ],
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.24.0",
28
+ "@babel/runtime": "^7.24.4",
29
29
  "complex.js": "^2.1.1",
30
30
  "decimal.js": "^10.4.3",
31
31
  "escape-latex": "^1.2.0",
@@ -36,36 +36,36 @@
36
36
  "typed-function": "^4.1.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.24.0",
40
- "@babel/plugin-transform-object-assign": "7.23.3",
41
- "@babel/plugin-transform-runtime": "7.24.0",
42
- "@babel/preset-env": "7.24.0",
39
+ "@babel/core": "7.24.4",
40
+ "@babel/plugin-transform-object-assign": "7.24.1",
41
+ "@babel/plugin-transform-runtime": "7.24.3",
42
+ "@babel/preset-env": "7.24.4",
43
43
  "@babel/register": "7.23.7",
44
44
  "@types/assert": "1.5.10",
45
45
  "@types/mocha": "10.0.6",
46
- "@typescript-eslint/eslint-plugin": "7.2.0",
47
- "@typescript-eslint/parser": "7.2.0",
46
+ "@typescript-eslint/eslint-plugin": "7.7.1",
47
+ "@typescript-eslint/parser": "7.7.1",
48
48
  "assert": "2.1.0",
49
49
  "babel-loader": "9.1.3",
50
50
  "benchmark": "2.1.4",
51
51
  "c8": "9.1.0",
52
52
  "codecov": "3.8.3",
53
- "core-js": "3.36.0",
53
+ "core-js": "3.37.0",
54
54
  "del": "6.1.1",
55
55
  "dtslint": "4.2.1",
56
56
  "eslint": "8.57.0",
57
57
  "eslint-config-prettier": "9.1.0",
58
58
  "eslint-config-standard": "17.1.0",
59
59
  "eslint-plugin-import": "2.29.1",
60
- "eslint-plugin-mocha": "10.4.1",
60
+ "eslint-plugin-mocha": "10.4.3",
61
61
  "eslint-plugin-n": "16.6.2",
62
62
  "eslint-plugin-prettier": "5.1.3",
63
63
  "eslint-plugin-promise": "6.1.1",
64
- "expect-type": "0.18.0",
64
+ "expect-type": "0.19.0",
65
65
  "expr-eval": "2.0.2",
66
66
  "fancy-log": "2.0.0",
67
67
  "glob": "8.1.0",
68
- "gulp": "4.0.2",
68
+ "gulp": "5.0.0",
69
69
  "gulp-babel": "8.0.0",
70
70
  "handlebars": "4.7.8",
71
71
  "jsep": "1.3.8",
@@ -76,7 +76,7 @@
76
76
  "karma-mocha-reporter": "2.2.5",
77
77
  "karma-webpack": "5.0.1",
78
78
  "mkdirp": "3.0.1",
79
- "mocha": "10.3.0",
79
+ "mocha": "10.4.0",
80
80
  "mocha-junit-reporter": "2.2.1",
81
81
  "ndarray": "1.0.19",
82
82
  "ndarray-determinant": "1.0.0",
@@ -89,8 +89,8 @@
89
89
  "process": "0.11.10",
90
90
  "sylvester": "0.0.21",
91
91
  "ts-node": "10.9.2",
92
- "typescript": "5.4.2",
93
- "webpack": "5.90.3",
92
+ "typescript": "5.4.5",
93
+ "webpack": "5.91.0",
94
94
  "zeros": "1.0.0"
95
95
  },
96
96
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  # Mathjs TypeScript types
2
2
 
3
- The code base of Mathjs is writting in JavaScript. The TypeScript definitions are maintained separately.
3
+ The code base of Mathjs is written in JavaScript. The TypeScript definitions are maintained separately.
4
4
 
5
5
  ## Library structure
6
6
 
@@ -52,3 +52,15 @@ export const {
52
52
  // ...
53
53
  } : Record<string, FactoryFunctionMap>
54
54
  ```
55
+
56
+ ## Testing the type definitions
57
+
58
+ The types are defined in `types/index.d.ts`.
59
+
60
+ The tests for the type definitions are located in `test/typescript-types/testTypes.ts`.
61
+
62
+ To run the tests for the type definitions:
63
+
64
+ ```
65
+ npm run test:types
66
+ ```
package/types/index.d.ts CHANGED
@@ -1036,7 +1036,9 @@ export interface MathJsInstance extends MathJsFactory {
1036
1036
  * @returns Sum of x and y
1037
1037
  */
1038
1038
  add<T extends MathType>(x: T, y: T): T
1039
+ add<T extends MathType>(...values: T[]): T
1039
1040
  add(x: MathType, y: MathType): MathType
1041
+ add(...values: MathType[]): MathType
1040
1042
 
1041
1043
  /**
1042
1044
  * Calculate the cubic root of a value.
@@ -1283,6 +1285,8 @@ export interface MathJsInstance extends MathJsFactory {
1283
1285
  multiply(x: Unit, y: Unit): Unit
1284
1286
  multiply(x: number, y: number): number
1285
1287
  multiply(x: MathType, y: MathType): MathType
1288
+ multiply<T extends MathType>(...values: T[]): T
1289
+ multiply(...values: MathType[]): MathType
1286
1290
 
1287
1291
  /**
1288
1292
  * Calculate the norm of a number, vector or matrix. The second
@@ -2801,6 +2805,19 @@ export interface MathJsInstance extends MathJsFactory {
2801
2805
  */
2802
2806
  prod(A: MathCollection): MathScalarType
2803
2807
 
2808
+ /**
2809
+ * @param A A single matrix
2810
+ * @param probOrN prob is the order of the quantile, while N is the
2811
+ * amount of evenly distributed steps of probabilities; only one of
2812
+ * these options can be provided
2813
+ * @param sorted =false is data sorted in ascending order
2814
+ * @returns Quantile(s)
2815
+ */
2816
+ quantileSeq<T extends MathScalarType>(
2817
+ A: T[] | T[][],
2818
+ prob: number | BigNumber | MathArray,
2819
+ sorted?: boolean
2820
+ ): T
2804
2821
  /**
2805
2822
  * Compute the prob order quantile of a matrix or a list with values.
2806
2823
  * The sequence is sorted and the middle value is returned. Supported
@@ -2819,7 +2836,7 @@ export interface MathJsInstance extends MathJsFactory {
2819
2836
  A: MathCollection,
2820
2837
  prob: number | BigNumber | MathArray,
2821
2838
  sorted?: boolean
2822
- ): number | BigNumber | Unit | MathArray
2839
+ ): MathScalarType | MathArray
2823
2840
 
2824
2841
  /**
2825
2842
  * Compute the standard deviation of a matrix or a list with values. The