@danielsimonjr/mathts-expression 0.2.0 → 0.2.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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +29 -18
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2992,7 +2992,6 @@ declare const createArrayNode: FactoryFunction<{
|
|
|
2992
2992
|
|
|
2993
2993
|
declare const createAssignmentNode: FactoryFunction<{
|
|
2994
2994
|
subset: any;
|
|
2995
|
-
matrix: any;
|
|
2996
2995
|
Node: new (...args: any[]) => MathNode;
|
|
2997
2996
|
}, {
|
|
2998
2997
|
new (object: MathNode, index: any, value?: MathNode): {
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
|
|
8
|
+
try {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw mod = 0, e;
|
|
12
|
+
}
|
|
9
13
|
};
|
|
10
14
|
var __copyProps = (to, from, except, desc) => {
|
|
11
15
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -649,6 +653,22 @@ function getOperator(fn) {
|
|
|
649
653
|
return null;
|
|
650
654
|
}
|
|
651
655
|
|
|
656
|
+
// src/error/MathjsError.ts
|
|
657
|
+
var MathjsError = class _MathjsError extends Error {
|
|
658
|
+
isMathjsError = true;
|
|
659
|
+
/**
|
|
660
|
+
* Create a MathjsError
|
|
661
|
+
* @param message Error message
|
|
662
|
+
*/
|
|
663
|
+
constructor(message) {
|
|
664
|
+
super(message);
|
|
665
|
+
this.name = "MathjsError";
|
|
666
|
+
if (Error.captureStackTrace) {
|
|
667
|
+
Error.captureStackTrace(this, _MathjsError);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
|
|
652
672
|
// src/utils/factory.ts
|
|
653
673
|
function factory(name20, dependencies20, create, meta) {
|
|
654
674
|
function assertAndCreate(scope) {
|
|
@@ -670,7 +690,7 @@ function assertDependencies(name20, dependencies20, scope) {
|
|
|
670
690
|
const missingDependencies = dependencies20.filter(
|
|
671
691
|
(dependency) => scope[dependency] === void 0
|
|
672
692
|
);
|
|
673
|
-
throw new
|
|
693
|
+
throw new MathjsError(
|
|
674
694
|
`Cannot create function "${name20}", some dependencies are missing: ${missingDependencies.map((d) => `"${d}"`).join(", ")}.`
|
|
675
695
|
);
|
|
676
696
|
}
|
|
@@ -3992,13 +4012,13 @@ var createArrayNode = /* @__PURE__ */ factory(
|
|
|
3992
4012
|
);
|
|
3993
4013
|
|
|
3994
4014
|
// src/node/utils/assign.ts
|
|
3995
|
-
function assignFactory({ subset
|
|
4015
|
+
function assignFactory({ subset }) {
|
|
3996
4016
|
return function assign(object, index, value) {
|
|
3997
4017
|
try {
|
|
3998
4018
|
if (Array.isArray(object)) {
|
|
3999
|
-
const result =
|
|
4000
|
-
result.forEach((item,
|
|
4001
|
-
object[
|
|
4019
|
+
const result = subset(object, index, value);
|
|
4020
|
+
result.forEach((item, i) => {
|
|
4021
|
+
object[i] = item;
|
|
4002
4022
|
});
|
|
4003
4023
|
return object;
|
|
4004
4024
|
} else if (object && typeof object.subset === "function") {
|
|
@@ -4022,22 +4042,13 @@ function assignFactory({ subset, matrix }) {
|
|
|
4022
4042
|
|
|
4023
4043
|
// src/node/AssignmentNode.ts
|
|
4024
4044
|
var name7 = "AssignmentNode";
|
|
4025
|
-
var dependencies7 = [
|
|
4026
|
-
"subset",
|
|
4027
|
-
"?matrix",
|
|
4028
|
-
// FIXME: should not be needed at all, should be handled by subset
|
|
4029
|
-
"Node"
|
|
4030
|
-
];
|
|
4045
|
+
var dependencies7 = ["subset", "Node"];
|
|
4031
4046
|
var createAssignmentNode = /* @__PURE__ */ factory(
|
|
4032
4047
|
name7,
|
|
4033
4048
|
dependencies7,
|
|
4034
|
-
({
|
|
4035
|
-
subset,
|
|
4036
|
-
matrix,
|
|
4037
|
-
Node
|
|
4038
|
-
}) => {
|
|
4049
|
+
({ subset, Node }) => {
|
|
4039
4050
|
const access = accessFactory({ subset });
|
|
4040
|
-
const assign = assignFactory({ subset
|
|
4051
|
+
const assign = assignFactory({ subset });
|
|
4041
4052
|
function needParenthesis(node, parenthesis, implicit) {
|
|
4042
4053
|
if (!parenthesis) {
|
|
4043
4054
|
parenthesis = "keep";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-expression",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Expression parser and evaluator for MathTS",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@danielsimonjr/mathts-core": "
|
|
34
|
+
"@danielsimonjr/mathts-core": "0.1.3",
|
|
35
35
|
"typed-function": "^4.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|