mathjs 13.2.0 → 13.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +8 -1
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -9
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/function/typed.js +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesParserClass.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +0 -18
- package/lib/cjs/entry/dependenciesNumber/dependenciesParserClass.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +0 -14
- package/lib/cjs/entry/impureFunctionsAny.generated.js +2 -12
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +2 -10
- package/lib/cjs/expression/Parser.js +21 -2
- package/lib/cjs/function/algebra/simplify.js +2 -13
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/matrix/MatrixIndex.js +3 -0
- package/lib/cjs/type/resultset/ResultSet.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/function/typed.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesParserClass.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +0 -18
- package/lib/esm/entry/dependenciesNumber/dependenciesParserClass.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +0 -14
- package/lib/esm/entry/impureFunctionsAny.generated.js +2 -12
- package/lib/esm/entry/impureFunctionsNumber.generated.js +2 -10
- package/lib/esm/expression/Parser.js +21 -2
- package/lib/esm/function/algebra/simplify.js +2 -13
- package/lib/esm/type/matrix/MatrixIndex.js +3 -0
- package/lib/esm/type/resultset/ResultSet.js +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +17 -17
@@ -157,11 +157,10 @@ export var Help = createHelpClass({
|
|
157
157
|
evaluate
|
158
158
|
});
|
159
159
|
export var Parser = createParserClass({
|
160
|
-
evaluate
|
160
|
+
evaluate,
|
161
|
+
parse
|
161
162
|
});
|
162
163
|
export var simplify = createSimplify({
|
163
|
-
bignumber,
|
164
|
-
fraction,
|
165
164
|
AccessorNode,
|
166
165
|
ArrayNode,
|
167
166
|
ConstantNode,
|
@@ -171,20 +170,11 @@ export var simplify = createSimplify({
|
|
171
170
|
OperatorNode,
|
172
171
|
ParenthesisNode,
|
173
172
|
SymbolNode,
|
174
|
-
add,
|
175
|
-
config,
|
176
|
-
divide,
|
177
173
|
equal,
|
178
|
-
isZero,
|
179
|
-
mathWithTransform,
|
180
|
-
matrix,
|
181
|
-
multiply,
|
182
174
|
parse,
|
183
|
-
pow,
|
184
175
|
resolve,
|
185
176
|
simplifyConstant,
|
186
177
|
simplifyCore,
|
187
|
-
subtract,
|
188
178
|
typed
|
189
179
|
});
|
190
180
|
export var symbolicEqual = createSymbolicEqual({
|
@@ -154,7 +154,8 @@ export var Help = createHelpClass({
|
|
154
154
|
evaluate
|
155
155
|
});
|
156
156
|
export var Parser = createParserClass({
|
157
|
-
evaluate
|
157
|
+
evaluate,
|
158
|
+
parse
|
158
159
|
});
|
159
160
|
export var simplify = createSimplify({
|
160
161
|
AccessorNode,
|
@@ -166,20 +167,11 @@ export var simplify = createSimplify({
|
|
166
167
|
OperatorNode,
|
167
168
|
ParenthesisNode,
|
168
169
|
SymbolNode,
|
169
|
-
add,
|
170
|
-
config,
|
171
|
-
divide,
|
172
170
|
equal,
|
173
|
-
isZero,
|
174
|
-
mathWithTransform,
|
175
|
-
matrix,
|
176
|
-
multiply,
|
177
171
|
parse,
|
178
|
-
pow,
|
179
172
|
resolve,
|
180
173
|
simplifyConstant,
|
181
174
|
simplifyCore,
|
182
|
-
subtract,
|
183
175
|
typed
|
184
176
|
});
|
185
177
|
export var derivative = createDerivative({
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { factory } from '../utils/factory.js';
|
2
2
|
import { createEmptyMap, toObject } from '../utils/map.js';
|
3
3
|
var name = 'Parser';
|
4
|
-
var dependencies = ['evaluate'];
|
4
|
+
var dependencies = ['evaluate', 'parse'];
|
5
5
|
export var createParserClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
|
-
evaluate
|
7
|
+
evaluate,
|
8
|
+
parse
|
8
9
|
} = _ref;
|
9
10
|
/**
|
10
11
|
* @constructor Parser
|
@@ -110,6 +111,21 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
110
111
|
Parser.prototype.getAllAsMap = function () {
|
111
112
|
return this.scope;
|
112
113
|
};
|
114
|
+
function isValidVariableName(name) {
|
115
|
+
if (name.length === 0) {
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
for (var i = 0; i < name.length; i++) {
|
119
|
+
var cPrev = name.charAt(i - 1);
|
120
|
+
var c = name.charAt(i);
|
121
|
+
var cNext = name.charAt(i + 1);
|
122
|
+
var valid = parse.isAlpha(c, cPrev, cNext) || i > 0 && parse.isDigit(c);
|
123
|
+
if (!valid) {
|
124
|
+
return false;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
return true;
|
128
|
+
}
|
113
129
|
|
114
130
|
/**
|
115
131
|
* Set a symbol (a function or variable) by name from the parsers scope.
|
@@ -117,6 +133,9 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
117
133
|
* @param {* | undefined} value
|
118
134
|
*/
|
119
135
|
Parser.prototype.set = function (name, value) {
|
136
|
+
if (!isValidVariableName(name)) {
|
137
|
+
throw new Error("Invalid variable name: '".concat(name, "'. Variable names must follow the specified rules."));
|
138
|
+
}
|
120
139
|
this.scope.set(name, value);
|
121
140
|
return value;
|
122
141
|
};
|
@@ -5,26 +5,15 @@ import { createUtil } from './simplify/util.js';
|
|
5
5
|
import { hasOwnProperty } from '../../utils/object.js';
|
6
6
|
import { createEmptyMap, createMap } from '../../utils/map.js';
|
7
7
|
var name = 'simplify';
|
8
|
-
var dependencies = ['
|
8
|
+
var dependencies = ['typed', 'parse', 'equal', 'resolve', 'simplifyConstant', 'simplifyCore', 'AccessorNode', 'ArrayNode', 'ConstantNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode', 'SymbolNode'];
|
9
9
|
export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
10
10
|
var {
|
11
|
-
config,
|
12
11
|
typed,
|
13
12
|
parse,
|
14
|
-
add,
|
15
|
-
subtract,
|
16
|
-
multiply,
|
17
|
-
divide,
|
18
|
-
pow,
|
19
|
-
isZero,
|
20
13
|
equal,
|
21
14
|
resolve,
|
22
15
|
simplifyConstant,
|
23
16
|
simplifyCore,
|
24
|
-
fraction,
|
25
|
-
bignumber,
|
26
|
-
mathWithTransform,
|
27
|
-
matrix,
|
28
17
|
AccessorNode,
|
29
18
|
ArrayNode,
|
30
19
|
ConstantNode,
|
@@ -189,7 +178,7 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
189
178
|
simplify.realContext = realContext;
|
190
179
|
simplify.positiveContext = positiveContext;
|
191
180
|
function removeParens(node) {
|
192
|
-
return node.transform(function (node
|
181
|
+
return node.transform(function (node) {
|
193
182
|
return isParenthesisNode(node) ? removeParens(node.content) : node;
|
194
183
|
});
|
195
184
|
}
|
@@ -180,6 +180,9 @@ export var createIndexClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
180
180
|
* @returns {Range | null} range
|
181
181
|
*/
|
182
182
|
Index.prototype.dimension = function (dim) {
|
183
|
+
if (typeof dim !== 'number') {
|
184
|
+
return null;
|
185
|
+
}
|
183
186
|
return this._dimensions[dim] || null;
|
184
187
|
};
|
185
188
|
|
@@ -36,7 +36,7 @@ export var createResultSet = /* #__PURE__ */factory(name, dependencies, () => {
|
|
36
36
|
* @returns {string} string
|
37
37
|
*/
|
38
38
|
ResultSet.prototype.toString = function () {
|
39
|
-
return '[' + this.entries.join(', ') + ']';
|
39
|
+
return '[' + this.entries.map(String).join(', ') + ']';
|
40
40
|
};
|
41
41
|
|
42
42
|
/**
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "13.2.
|
3
|
+
"version": "13.2.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,8 +25,8 @@
|
|
25
25
|
"unit"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@babel/runtime": "^7.25.
|
29
|
-
"complex.js": "^2.
|
28
|
+
"@babel/runtime": "^7.25.7",
|
29
|
+
"complex.js": "^2.2.5",
|
30
30
|
"decimal.js": "^10.4.3",
|
31
31
|
"escape-latex": "^1.2.0",
|
32
32
|
"fraction.js": "^4.3.7",
|
@@ -36,14 +36,14 @@
|
|
36
36
|
"typed-function": "^4.2.1"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.
|
40
|
-
"@babel/plugin-transform-object-assign": "7.
|
41
|
-
"@babel/plugin-transform-optional-catch-binding": "7.
|
42
|
-
"@babel/plugin-transform-runtime": "7.25.
|
43
|
-
"@babel/preset-env": "7.
|
44
|
-
"@babel/register": "7.
|
45
|
-
"@types/assert": "1.5.
|
46
|
-
"@types/mocha": "10.0.
|
39
|
+
"@babel/core": "7.26.0",
|
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.25.9",
|
43
|
+
"@babel/preset-env": "7.26.0",
|
44
|
+
"@babel/register": "7.25.9",
|
45
|
+
"@types/assert": "1.5.11",
|
46
|
+
"@types/mocha": "10.0.9",
|
47
47
|
"@typescript-eslint/eslint-plugin": "7.16.1",
|
48
48
|
"@typescript-eslint/parser": "7.16.1",
|
49
49
|
"assert": "2.1.0",
|
@@ -51,18 +51,18 @@
|
|
51
51
|
"benchmark": "2.1.4",
|
52
52
|
"c8": "10.1.2",
|
53
53
|
"codecov": "3.8.3",
|
54
|
-
"core-js": "3.
|
55
|
-
"del": "
|
54
|
+
"core-js": "3.39.0",
|
55
|
+
"del": "8.0.0",
|
56
56
|
"dtslint": "4.2.1",
|
57
57
|
"eslint": "8.57.0",
|
58
58
|
"eslint-config-prettier": "9.1.0",
|
59
59
|
"eslint-config-standard": "17.1.0",
|
60
|
-
"eslint-plugin-import": "2.
|
60
|
+
"eslint-plugin-import": "2.31.0",
|
61
61
|
"eslint-plugin-mocha": "10.5.0",
|
62
62
|
"eslint-plugin-n": "16.6.2",
|
63
63
|
"eslint-plugin-prettier": "5.2.1",
|
64
64
|
"eslint-plugin-promise": "6.6.0",
|
65
|
-
"expect-type": "
|
65
|
+
"expect-type": "1.1.0",
|
66
66
|
"expr-eval": "2.0.2",
|
67
67
|
"fancy-log": "2.0.0",
|
68
68
|
"glob": "11.0.0",
|
@@ -77,7 +77,7 @@
|
|
77
77
|
"karma-mocha-reporter": "2.2.5",
|
78
78
|
"karma-webpack": "5.0.1",
|
79
79
|
"mkdirp": "3.0.1",
|
80
|
-
"mocha": "10.
|
80
|
+
"mocha": "10.8.2",
|
81
81
|
"mocha-junit-reporter": "2.2.1",
|
82
82
|
"ndarray": "1.0.19",
|
83
83
|
"ndarray-determinant": "1.0.0",
|
@@ -92,7 +92,7 @@
|
|
92
92
|
"sylvester": "0.0.21",
|
93
93
|
"ts-node": "10.9.2",
|
94
94
|
"typescript": "5.5.4",
|
95
|
-
"webpack": "5.
|
95
|
+
"webpack": "5.96.1",
|
96
96
|
"zeros": "1.0.0"
|
97
97
|
},
|
98
98
|
"type": "module",
|