mathjs 11.9.0 → 11.9.1

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.
@@ -237,7 +237,7 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
237
237
  // the function symbol is an argName
238
238
  var _rawArgs = this.args;
239
239
  return function evalFunctionNode(scope, args, context) {
240
- var fn = args[_name];
240
+ var fn = (0, _customs.getSafeProperty)(args, _name);
241
241
  if (typeof fn !== 'function') {
242
242
  throw new TypeError("Argument '".concat(_name, "' was not a function; received: ").concat(strin(fn)));
243
243
  }
@@ -261,17 +261,16 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
261
261
  var _rawArgs2 = this.args;
262
262
  return function evalFunctionNode(scope, args, context) {
263
263
  var object = evalObject(scope, args, context);
264
- (0, _customs.validateSafeMethod)(object, prop);
265
- var isRaw = object[prop] && object[prop].rawArgs;
266
- if (isRaw) {
264
+ var fn = (0, _customs.getSafeMethod)(object, prop);
265
+ if (fn !== null && fn !== void 0 && fn.rawArgs) {
267
266
  // "Raw" evaluation
268
- return object[prop](_rawArgs2, math, (0, _scope.createSubScope)(scope, args), scope);
267
+ return fn(_rawArgs2, math, (0, _scope.createSubScope)(scope, args), scope);
269
268
  } else {
270
269
  // "regular" evaluation
271
270
  var values = evalArgs.map(function (evalArg) {
272
271
  return evalArg(scope, args, context);
273
272
  });
274
- return object[prop].apply(object, values);
273
+ return fn.apply(object, values);
275
274
  }
276
275
  };
277
276
  } else {
@@ -12,11 +12,11 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
12
12
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _is = require("../../utils/is.js");
16
- var _string = require("../../utils/string.js");
17
15
  var _customs = require("../../utils/customs.js");
18
- var _object = require("../../utils/object.js");
19
16
  var _factory = require("../../utils/factory.js");
17
+ var _is = require("../../utils/is.js");
18
+ var _object = require("../../utils/object.js");
19
+ var _string = require("../../utils/string.js");
20
20
  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); }; }
21
21
  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; } }
22
22
  var name = 'ObjectNode';
@@ -82,10 +82,8 @@ var createObjectNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies,
82
82
  // so you cannot create a key like {"co\\u006Estructor": null}
83
83
  var stringifiedKey = (0, _string.stringify)(key);
84
84
  var parsedKey = JSON.parse(stringifiedKey);
85
- if (!(0, _customs.isSafeProperty)(this.properties, parsedKey)) {
86
- throw new Error('No access to property "' + parsedKey + '"');
87
- }
88
- evalEntries[parsedKey] = this.properties[key]._compile(math, argNames);
85
+ var prop = (0, _customs.getSafeProperty)(this.properties, key);
86
+ evalEntries[parsedKey] = prop._compile(math, argNames);
89
87
  }
90
88
  }
91
89
  return function evalObjectNode(scope, args, context) {
@@ -84,7 +84,7 @@ var createSymbolNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies,
84
84
  // (like an x when inside the expression of a function
85
85
  // assignment `f(x) = ...`)
86
86
  return function (scope, args, context) {
87
- return args[name];
87
+ return (0, _customs.getSafeProperty)(args, name);
88
88
  };
89
89
  } else if (name in math) {
90
90
  return function (scope, args, context) {
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.9.0
10
- * @date 2023-07-19
9
+ * @version 11.9.1
10
+ * @date 2023-07-24
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2023 Jos de Jong <wjosdejong@gmail.com>
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.getSafeMethod = getSafeMethod;
7
8
  exports.getSafeProperties = getSafeProperties;
8
9
  exports.getSafeProperty = getSafeProperty;
9
10
  exports.hasSafeProperty = hasSafeProperty;
@@ -11,7 +12,6 @@ exports.isPlainObject = isPlainObject;
11
12
  exports.isSafeMethod = isSafeMethod;
12
13
  exports.isSafeProperty = isSafeProperty;
13
14
  exports.setSafeProperty = setSafeProperty;
14
- exports.validateSafeMethod = validateSafeMethod;
15
15
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
16
16
  var _object = require("./object.js");
17
17
  /**
@@ -99,12 +99,13 @@ function isSafeProperty(object, prop) {
99
99
  * Throws an error when that's not the case.
100
100
  * @param {Object} object
101
101
  * @param {string} method
102
+ * @return {function} Returns the method when valid
102
103
  */
103
- // TODO: merge this function into assign.js?
104
- function validateSafeMethod(object, method) {
104
+ function getSafeMethod(object, method) {
105
105
  if (!isSafeMethod(object, method)) {
106
106
  throw new Error('No access to method "' + method + '"');
107
107
  }
108
+ return object[method];
108
109
  }
109
110
 
110
111
  /**
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '11.9.0';
7
+ var version = '11.9.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;
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { isAccessorNode, isFunctionAssignmentNode, isIndexNode, isNode, isSymbolNode } from '../../utils/is.js';
3
3
  import { escape, format } from '../../utils/string.js';
4
4
  import { hasOwnProperty } from '../../utils/object.js';
5
- import { getSafeProperty, validateSafeMethod } from '../../utils/customs.js';
5
+ import { getSafeProperty, getSafeMethod } from '../../utils/customs.js';
6
6
  import { createSubScope } from '../../utils/scope.js';
7
7
  import { factory } from '../../utils/factory.js';
8
8
  import { defaultTemplate, latexFunctions } from '../../utils/latex.js';
@@ -203,7 +203,7 @@ export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, _ref
203
203
  // the function symbol is an argName
204
204
  var _rawArgs = this.args;
205
205
  return function evalFunctionNode(scope, args, context) {
206
- var fn = args[_name];
206
+ var fn = getSafeProperty(args, _name);
207
207
  if (typeof fn !== 'function') {
208
208
  throw new TypeError("Argument '".concat(_name, "' was not a function; received: ").concat(strin(fn)));
209
209
  }
@@ -225,15 +225,14 @@ export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, _ref
225
225
  var _rawArgs2 = this.args;
226
226
  return function evalFunctionNode(scope, args, context) {
227
227
  var object = evalObject(scope, args, context);
228
- validateSafeMethod(object, prop);
229
- var isRaw = object[prop] && object[prop].rawArgs;
230
- if (isRaw) {
228
+ var fn = getSafeMethod(object, prop);
229
+ if (fn !== null && fn !== void 0 && fn.rawArgs) {
231
230
  // "Raw" evaluation
232
- return object[prop](_rawArgs2, math, createSubScope(scope, args), scope);
231
+ return fn(_rawArgs2, math, createSubScope(scope, args), scope);
233
232
  } else {
234
233
  // "regular" evaluation
235
234
  var values = evalArgs.map(evalArg => evalArg(scope, args, context));
236
- return object[prop].apply(object, values);
235
+ return fn.apply(object, values);
237
236
  }
238
237
  };
239
238
  } else {
@@ -1,9 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { getSafeProperty } from '../../utils/customs.js';
3
+ import { factory } from '../../utils/factory.js';
2
4
  import { isNode } from '../../utils/is.js';
3
- import { escape, stringify } from '../../utils/string.js';
4
- import { isSafeProperty } from '../../utils/customs.js';
5
5
  import { hasOwnProperty } from '../../utils/object.js';
6
- import { factory } from '../../utils/factory.js';
6
+ import { escape, stringify } from '../../utils/string.js';
7
7
  var name = 'ObjectNode';
8
8
  var dependencies = ['Node'];
9
9
  export var createObjectNode = /* #__PURE__ */factory(name, dependencies, _ref => {
@@ -58,10 +58,8 @@ export var createObjectNode = /* #__PURE__ */factory(name, dependencies, _ref =>
58
58
  // so you cannot create a key like {"co\\u006Estructor": null}
59
59
  var stringifiedKey = stringify(key);
60
60
  var parsedKey = JSON.parse(stringifiedKey);
61
- if (!isSafeProperty(this.properties, parsedKey)) {
62
- throw new Error('No access to property "' + parsedKey + '"');
63
- }
64
- evalEntries[parsedKey] = this.properties[key]._compile(math, argNames);
61
+ var prop = getSafeProperty(this.properties, key);
62
+ evalEntries[parsedKey] = prop._compile(math, argNames);
65
63
  }
66
64
  }
67
65
  return function evalObjectNode(scope, args, context) {
@@ -61,7 +61,7 @@ export var createSymbolNode = /* #__PURE__ */factory(name, dependencies, _ref =>
61
61
  // (like an x when inside the expression of a function
62
62
  // assignment `f(x) = ...`)
63
63
  return function (scope, args, context) {
64
- return args[name];
64
+ return getSafeProperty(args, name);
65
65
  };
66
66
  } else if (name in math) {
67
67
  return function (scope, args, context) {
@@ -83,12 +83,13 @@ function isSafeProperty(object, prop) {
83
83
  * Throws an error when that's not the case.
84
84
  * @param {Object} object
85
85
  * @param {string} method
86
+ * @return {function} Returns the method when valid
86
87
  */
87
- // TODO: merge this function into assign.js?
88
- function validateSafeMethod(object, method) {
88
+ function getSafeMethod(object, method) {
89
89
  if (!isSafeMethod(object, method)) {
90
90
  throw new Error('No access to method "' + method + '"');
91
91
  }
92
+ return object[method];
92
93
  }
93
94
 
94
95
  /**
@@ -148,6 +149,6 @@ export { setSafeProperty };
148
149
  export { isSafeProperty };
149
150
  export { hasSafeProperty };
150
151
  export { getSafeProperties };
151
- export { validateSafeMethod };
152
+ export { getSafeMethod };
152
153
  export { isSafeMethod };
153
154
  export { isPlainObject };
@@ -1,3 +1,3 @@
1
- export var version = '11.9.0';
1
+ export var version = '11.9.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.9.0",
3
+ "version": "11.9.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",
@@ -25,7 +25,7 @@
25
25
  "unit"
26
26
  ],
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.22.5",
28
+ "@babel/runtime": "^7.22.6",
29
29
  "complex.js": "^2.1.1",
30
30
  "decimal.js": "^10.4.3",
31
31
  "escape-latex": "^1.2.0",
@@ -36,29 +36,29 @@
36
36
  "typed-function": "^4.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.22.5",
39
+ "@babel/core": "7.22.9",
40
40
  "@babel/plugin-transform-object-assign": "7.22.5",
41
- "@babel/plugin-transform-runtime": "7.22.5",
42
- "@babel/preset-env": "7.22.5",
41
+ "@babel/plugin-transform-runtime": "7.22.9",
42
+ "@babel/preset-env": "7.22.9",
43
43
  "@babel/register": "7.22.5",
44
44
  "@types/assert": "1.5.6",
45
45
  "@types/mocha": "10.0.1",
46
- "@typescript-eslint/eslint-plugin": "5.60.0",
47
- "@typescript-eslint/parser": "5.60.0",
46
+ "@typescript-eslint/eslint-plugin": "6.1.0",
47
+ "@typescript-eslint/parser": "6.1.0",
48
48
  "assert": "2.0.0",
49
- "babel-loader": "9.1.2",
49
+ "babel-loader": "9.1.3",
50
50
  "benchmark": "2.1.4",
51
51
  "c8": "8.0.0",
52
52
  "codecov": "3.8.3",
53
- "core-js": "3.31.0",
53
+ "core-js": "3.31.1",
54
54
  "del": "6.1.1",
55
55
  "dtslint": "4.2.1",
56
- "eslint": "8.43.0",
56
+ "eslint": "8.45.0",
57
57
  "eslint-config-prettier": "8.8.0",
58
58
  "eslint-config-standard": "17.1.0",
59
59
  "eslint-plugin-import": "2.27.5",
60
60
  "eslint-plugin-mocha": "10.1.0",
61
- "eslint-plugin-n": "16.0.0",
61
+ "eslint-plugin-n": "16.0.1",
62
62
  "eslint-plugin-prettier": "4.2.1",
63
63
  "eslint-plugin-promise": "6.1.1",
64
64
  "expect-type": "0.16.0",
@@ -75,9 +75,9 @@
75
75
  "karma-mocha": "2.0.1",
76
76
  "karma-mocha-reporter": "2.2.5",
77
77
  "karma-webpack": "5.0.0",
78
- "mkdirp": "2.1.6",
78
+ "mkdirp": "3.0.1",
79
79
  "mocha": "10.2.0",
80
- "mocha-junit-reporter": "2.2.0",
80
+ "mocha-junit-reporter": "2.2.1",
81
81
  "ndarray": "1.0.19",
82
82
  "ndarray-determinant": "1.0.0",
83
83
  "ndarray-gemm": "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.1",
92
- "typescript": "5.1.3",
93
- "webpack": "5.87.0",
92
+ "typescript": "5.1.6",
93
+ "webpack": "5.88.2",
94
94
  "zeros": "1.0.0"
95
95
  },
96
96
  "type": "module",