mathjs 11.3.0 → 11.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,9 @@ var _array = require("../../utils/array.js");
18
18
  var _latex = require("../../utils/latex.js");
19
19
  var _operators = require("../operators.js");
20
20
  var _factory = require("../../utils/factory.js");
21
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
22
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
22
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
23
26
  var name = 'FunctionAssignmentNode';
@@ -69,6 +72,24 @@ var createFunctionAssignmentNode = /* #__PURE__ */(0, _factory.factory)(name, de
69
72
  if (_keywords.keywords.has(name)) {
70
73
  throw new Error('Illegal function name, "' + name + '" is a reserved keyword');
71
74
  }
75
+ var paramNames = new Set();
76
+ var _iterator = _createForOfIteratorHelper(params),
77
+ _step;
78
+ try {
79
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
80
+ var param = _step.value;
81
+ var _name = typeof param === 'string' ? param : param.name;
82
+ if (paramNames.has(_name)) {
83
+ throw new Error("Duplicate parameter name \"".concat(_name, "\""));
84
+ } else {
85
+ paramNames.add(_name);
86
+ }
87
+ }
88
+ } catch (err) {
89
+ _iterator.e(err);
90
+ } finally {
91
+ _iterator.f();
92
+ }
72
93
  _this.name = name;
73
94
  _this.params = params.map(function (param) {
74
95
  return param && param.name || param;
package/lib/cjs/header.js CHANGED
@@ -6,8 +6,8 @@
6
6
  * It features real and complex numbers, units, matrices, a large set of
7
7
  * mathematical functions, and a flexible expression parser.
8
8
  *
9
- * @version 11.3.0
10
- * @date 2022-10-11
9
+ * @version 11.3.1
10
+ * @date 2022-10-19
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
@@ -3677,14 +3677,9 @@ var createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
3677
3677
  * base unit, the name of the newly create base unit. Otherwise, this property
3678
3678
  * has no effect.
3679
3679
  *
3680
- * @param {Object} options (optional) An object containing any of the following
3681
- * properties:
3682
- * - override {boolean} Whether this unit should be allowed to override existing
3683
- * units.
3684
- *
3685
3680
  * @return {Unit}
3686
3681
  */
3687
- Unit.createUnitSingle = function (name, obj, options) {
3682
+ Unit.createUnitSingle = function (name, obj) {
3688
3683
  if (typeof obj === 'undefined' || obj === null) {
3689
3684
  obj = {};
3690
3685
  }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '11.3.0';
7
+ var version = '11.3.1';
8
8
  // Note: This file is automatically generated when building math.js.
9
9
  // Changes made in this file will be overwritten.
10
10
  exports.version = version;
@@ -53,6 +53,15 @@ export var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependenc
53
53
  if (keywords.has(name)) {
54
54
  throw new Error('Illegal function name, "' + name + '" is a reserved keyword');
55
55
  }
56
+ var paramNames = new Set();
57
+ for (var param of params) {
58
+ var _name = typeof param === 'string' ? param : param.name;
59
+ if (paramNames.has(_name)) {
60
+ throw new Error("Duplicate parameter name \"".concat(_name, "\""));
61
+ } else {
62
+ paramNames.add(_name);
63
+ }
64
+ }
56
65
  this.name = name;
57
66
  this.params = params.map(function (param) {
58
67
  return param && param.name || param;
@@ -3663,14 +3663,9 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
3663
3663
  * base unit, the name of the newly create base unit. Otherwise, this property
3664
3664
  * has no effect.
3665
3665
  *
3666
- * @param {Object} options (optional) An object containing any of the following
3667
- * properties:
3668
- * - override {boolean} Whether this unit should be allowed to override existing
3669
- * units.
3670
- *
3671
3666
  * @return {Unit}
3672
3667
  */
3673
- Unit.createUnitSingle = function (name, obj, options) {
3668
+ Unit.createUnitSingle = function (name, obj) {
3674
3669
  if (typeof obj === 'undefined' || obj === null) {
3675
3670
  obj = {};
3676
3671
  }
@@ -1,3 +1,3 @@
1
- export var version = '11.3.0';
1
+ export var version = '11.3.1';
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": "11.3.0",
3
+ "version": "11.3.1",
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",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.19.4",
29
29
  "complex.js": "^2.1.1",
30
- "decimal.js": "^10.4.1",
30
+ "decimal.js": "^10.4.2",
31
31
  "escape-latex": "^1.2.0",
32
32
  "fraction.js": "^4.2.0",
33
33
  "javascript-natural-sort": "^0.7.1",
@@ -43,8 +43,8 @@
43
43
  "@babel/register": "7.18.9",
44
44
  "@types/assert": "1.5.6",
45
45
  "@types/mocha": "10.0.0",
46
- "@typescript-eslint/eslint-plugin": "5.40.0",
47
- "@typescript-eslint/parser": "5.40.0",
46
+ "@typescript-eslint/eslint-plugin": "5.40.1",
47
+ "@typescript-eslint/parser": "5.40.1",
48
48
  "assert": "2.0.0",
49
49
  "babel-loader": "8.2.5",
50
50
  "benchmark": "2.1.4",
@@ -59,7 +59,7 @@
59
59
  "eslint-plugin-mocha": "10.1.0",
60
60
  "eslint-plugin-n": "15.3.0",
61
61
  "eslint-plugin-prettier": "4.2.1",
62
- "eslint-plugin-promise": "6.0.1",
62
+ "eslint-plugin-promise": "6.1.0",
63
63
  "expect-type": "0.14.2",
64
64
  "expr-eval": "2.0.2",
65
65
  "fancy-log": "2.0.0",
@@ -77,7 +77,7 @@
77
77
  "karma-webpack": "5.0.0",
78
78
  "math-expression-evaluator": "1.4.0",
79
79
  "mkdirp": "1.0.4",
80
- "mocha": "10.0.0",
80
+ "mocha": "10.1.0",
81
81
  "mocha-junit-reporter": "2.1.0",
82
82
  "ndarray": "1.0.19",
83
83
  "ndarray-determinant": "1.0.0",
@@ -162,7 +162,7 @@
162
162
  "test:all": "npm run test:src && npm run test:generated && npm run test:node && npm run test:types",
163
163
  "test:browser": "karma start test/browser-test-config/local-karma.js",
164
164
  "test:browserstack": "karma start test/browser-test-config/browserstack-karma.js",
165
- "test:types": "cd types && tsc -p ./tsconfig.json && node --loader ts-node/esm ./index.ts",
165
+ "test:types": " tsc -p ./tsconfig.json && node --loader ts-node/esm ./test/typescript-tests/testTypes.ts",
166
166
  "coverage": "nyc --reporter=lcov --reporter=text-summary mocha test/unit-tests && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
167
167
  "prepublishOnly": "npm run test:all && npm run lint",
168
168
  "update-authors": "node ./tools/update-authors.js"
package/types/index.d.ts CHANGED
@@ -258,6 +258,8 @@ declare namespace math {
258
258
  }
259
259
  interface FunctionNodeCtor {
260
260
  new (fn: MathNode | string, args: MathNode[]): FunctionNode
261
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
262
+ onUndefinedFunction: (name: string) => any
261
263
  }
262
264
 
263
265
  interface IndexNode extends MathNode {
@@ -383,6 +385,8 @@ declare namespace math {
383
385
  }
384
386
  interface SymbolNodeCtor {
385
387
  new (name: string): SymbolNode
388
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
389
+ onUndefinedSymbol: (name: string) => any
386
390
  }
387
391
 
388
392
  /**