mevento 2.0.1 → 2.0.4
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/esm2020/lib/mevento.mjs +24 -10
- package/fesm2015/mevento.mjs +23 -9
- package/fesm2015/mevento.mjs.map +1 -1
- package/fesm2020/mevento.mjs +23 -9
- package/fesm2020/mevento.mjs.map +1 -1
- package/lib/mevento.d.ts +12 -4
- package/package.json +1 -1
package/fesm2015/mevento.mjs
CHANGED
|
@@ -879,14 +879,16 @@ class Parser {
|
|
|
879
879
|
return this._arrayExpression();
|
|
880
880
|
case TokenType.lbrace:
|
|
881
881
|
return this._objectExpression();
|
|
882
|
+
case TokenType.IF:
|
|
883
|
+
return this._ifStatement();
|
|
882
884
|
default:
|
|
883
885
|
return this._variable();
|
|
884
886
|
}
|
|
885
887
|
}
|
|
886
888
|
_term() {
|
|
887
889
|
let node = this._factor();
|
|
888
|
-
node = this._tryParsingMemberExpression(node);
|
|
889
890
|
node = this._tryParsingFunctionCall(node);
|
|
891
|
+
node = this._tryParsingMemberExpression(node);
|
|
890
892
|
return node;
|
|
891
893
|
}
|
|
892
894
|
_expression() {
|
|
@@ -1221,8 +1223,8 @@ class Parser {
|
|
|
1221
1223
|
case TokenType.eol:
|
|
1222
1224
|
this._eatEOL();
|
|
1223
1225
|
return this._statement();
|
|
1224
|
-
case TokenType.IF:
|
|
1225
|
-
|
|
1226
|
+
// case TokenType.IF:
|
|
1227
|
+
// return this._ifStatement();
|
|
1226
1228
|
case TokenType.WHILE_TILL:
|
|
1227
1229
|
return this._whileLoop();
|
|
1228
1230
|
case TokenType.FOR_LOOP:
|
|
@@ -1556,7 +1558,7 @@ class MEvento extends NodeVisitor {
|
|
|
1556
1558
|
if (op.type === TokenType.not) {
|
|
1557
1559
|
return _boolValue(argValue) === false;
|
|
1558
1560
|
}
|
|
1559
|
-
if (isNum(argValue)) {
|
|
1561
|
+
if (!isNum(argValue)) {
|
|
1560
1562
|
throw new Error(`Operation ${op.value} not allowed no num value`);
|
|
1561
1563
|
}
|
|
1562
1564
|
if (op.type === TokenType.plus) {
|
|
@@ -1769,8 +1771,11 @@ class MEvento extends NodeVisitor {
|
|
|
1769
1771
|
unregisterFunction(id) {
|
|
1770
1772
|
delete this._functionsRegistry[id];
|
|
1771
1773
|
}
|
|
1772
|
-
execute(source, cache = true) {
|
|
1774
|
+
execute(source, cache = true, input) {
|
|
1773
1775
|
const module = MEvento.compile(source, cache);
|
|
1776
|
+
if (input) {
|
|
1777
|
+
Object.keys(input).forEach(k => this.changeVariable(k, input[k]));
|
|
1778
|
+
}
|
|
1774
1779
|
return this.visit(module);
|
|
1775
1780
|
}
|
|
1776
1781
|
static compile(source, cache = false) {
|
|
@@ -1791,9 +1796,12 @@ class MEvento extends NodeVisitor {
|
|
|
1791
1796
|
static unregister(id) {
|
|
1792
1797
|
delete MEvento._globalFunctionsRegistry[id];
|
|
1793
1798
|
}
|
|
1794
|
-
static run(source, cache = false) {
|
|
1799
|
+
static run(source, cache = false, input) {
|
|
1795
1800
|
const mevento = new MEvento();
|
|
1796
1801
|
const module = MEvento.compile(source, cache);
|
|
1802
|
+
if (input) {
|
|
1803
|
+
Object.keys(input).forEach(k => mevento.changeVariable(k, input[k]));
|
|
1804
|
+
}
|
|
1797
1805
|
return mevento.visit(module);
|
|
1798
1806
|
}
|
|
1799
1807
|
static newInstance() {
|
|
@@ -1981,7 +1989,7 @@ class MEventoAsync extends MEvento {
|
|
|
1981
1989
|
if (op.type === TokenType.not) {
|
|
1982
1990
|
return _boolValue(argValue) === false;
|
|
1983
1991
|
}
|
|
1984
|
-
if (isNum(argValue)) {
|
|
1992
|
+
if (!isNum(argValue)) {
|
|
1985
1993
|
throw new Error(`Operation ${op.value} not allowed no num value`);
|
|
1986
1994
|
}
|
|
1987
1995
|
if (op.type === TokenType.plus) {
|
|
@@ -2194,16 +2202,22 @@ class MEventoAsync extends MEvento {
|
|
|
2194
2202
|
unregisterFunction(id) {
|
|
2195
2203
|
delete this._functionsRegistry[id];
|
|
2196
2204
|
}
|
|
2197
|
-
execute(source, cache = true) {
|
|
2205
|
+
execute(source, cache = true, input) {
|
|
2198
2206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2199
2207
|
const module = MEvento.compile(source, cache);
|
|
2208
|
+
if (input) {
|
|
2209
|
+
Object.keys(input).forEach(k => this.changeVariable(k, input[k]));
|
|
2210
|
+
}
|
|
2200
2211
|
return yield this.visit(module);
|
|
2201
2212
|
});
|
|
2202
2213
|
}
|
|
2203
|
-
static run(source, cache = false) {
|
|
2214
|
+
static run(source, cache = false, input) {
|
|
2204
2215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2205
2216
|
const mevento = new MEventoAsync();
|
|
2206
2217
|
const module = MEvento.compile(source, cache);
|
|
2218
|
+
if (input) {
|
|
2219
|
+
Object.keys(input).forEach(k => mevento.changeVariable(k, input[k]));
|
|
2220
|
+
}
|
|
2207
2221
|
return yield mevento.visit(module);
|
|
2208
2222
|
});
|
|
2209
2223
|
}
|