fig-tree-evaluator 2.5.0 → 2.5.2
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/README.md +5 -5
- package/build/FigTreeEvaluator.js +32 -75
- package/build/cache.js +29 -75
- package/build/evaluate.js +68 -159
- package/build/helpers.js +55 -133
- package/build/index.js +1 -1
- package/build/operators/_operatorUtils.js +48 -109
- package/build/operators/buildObject.js +26 -84
- package/build/operators/conditional.js +18 -70
- package/build/operators/count.js +14 -48
- package/build/operators/customFunctions.js +25 -95
- package/build/operators/divide.js +26 -61
- package/build/operators/equal.js +23 -57
- package/build/operators/getRequest.js +36 -97
- package/build/operators/graphQL.js +40 -101
- package/build/operators/greaterThan.js +20 -54
- package/build/operators/lessThan.js +20 -54
- package/build/operators/logicalAnd.js +16 -61
- package/build/operators/logicalOr.js +14 -48
- package/build/operators/match.js +38 -101
- package/build/operators/multiply.js +14 -48
- package/build/operators/notEqual.js +23 -57
- package/build/operators/objectProperties.js +21 -66
- package/build/operators/passThru.js +15 -58
- package/build/operators/pgSQL.js +54 -135
- package/build/operators/plus.js +24 -70
- package/build/operators/postRequest.js +28 -82
- package/build/operators/regex.js +24 -70
- package/build/operators/split.js +29 -74
- package/build/operators/stringSubstitution.js +25 -79
- package/build/operators/subtract.js +16 -50
- package/build/typeCheck.js +22 -27
- package/package.json +2 -2
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,67 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
12
|
exports.CONDITIONAL = void 0;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
case 2:
|
|
65
|
-
_a = _b.sent();
|
|
66
|
-
return [3, 5];
|
|
67
|
-
case 3: return [4, (0, evaluate_1.evaluatorFunction)(expression.valueIfFalse, config)];
|
|
68
|
-
case 4:
|
|
69
|
-
_a = _b.sent();
|
|
70
|
-
_b.label = 5;
|
|
71
|
-
case 5: return [2, _a];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}); };
|
|
75
|
-
var parseChildren = function (expression) {
|
|
76
|
-
var _a = expression.children, condition = _a[0], valueIfTrue = _a[1], valueIfFalse = _a[2];
|
|
77
|
-
return __assign(__assign({}, expression), { condition: condition, valueIfTrue: valueIfTrue, valueIfFalse: valueIfFalse });
|
|
13
|
+
const evaluate_1 = require("../evaluate");
|
|
14
|
+
const requiredProperties = ['condition', 'valueIfTrue', 'valueIfFalse'];
|
|
15
|
+
const operatorAliases = ['?', 'conditional', 'ifThen'];
|
|
16
|
+
const propertyAliases = { ifTrue: 'valueIfTrue', ifFalse: 'valueIfFalse', ifNot: 'valueIfFalse' };
|
|
17
|
+
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const condition = yield (0, evaluate_1.evaluatorFunction)(expression.condition, config);
|
|
19
|
+
return !!condition
|
|
20
|
+
? yield (0, evaluate_1.evaluatorFunction)(expression.valueIfTrue, config)
|
|
21
|
+
: yield (0, evaluate_1.evaluatorFunction)(expression.valueIfFalse, config);
|
|
22
|
+
});
|
|
23
|
+
const parseChildren = (expression) => {
|
|
24
|
+
const [condition, valueIfTrue, valueIfFalse] = expression.children;
|
|
25
|
+
return Object.assign(Object.assign({}, expression), { condition, valueIfTrue, valueIfFalse });
|
|
78
26
|
};
|
|
79
27
|
exports.CONDITIONAL = {
|
|
80
|
-
requiredProperties
|
|
81
|
-
operatorAliases
|
|
82
|
-
propertyAliases
|
|
83
|
-
evaluate
|
|
84
|
-
parseChildren
|
|
28
|
+
requiredProperties,
|
|
29
|
+
operatorAliases,
|
|
30
|
+
propertyAliases,
|
|
31
|
+
evaluate,
|
|
32
|
+
parseChildren,
|
|
85
33
|
};
|
package/build/operators/count.js
CHANGED
|
@@ -8,56 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.COUNT = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
case 1:
|
|
51
|
-
values = _a.sent();
|
|
52
|
-
config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
|
|
53
|
-
return [2, values.length];
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}); };
|
|
13
|
+
const logicalAnd_1 = require("./logicalAnd");
|
|
14
|
+
const _operatorUtils_1 = require("./_operatorUtils");
|
|
15
|
+
const requiredProperties = ['values'];
|
|
16
|
+
const operatorAliases = ['count', 'length'];
|
|
17
|
+
const propertyAliases = {};
|
|
18
|
+
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const values = yield (0, _operatorUtils_1.evaluateArray)(expression.values, config);
|
|
20
|
+
config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
|
|
21
|
+
return values.length;
|
|
22
|
+
});
|
|
57
23
|
exports.COUNT = {
|
|
58
|
-
requiredProperties
|
|
59
|
-
operatorAliases
|
|
60
|
-
propertyAliases
|
|
61
|
-
evaluate
|
|
24
|
+
requiredProperties,
|
|
25
|
+
operatorAliases,
|
|
26
|
+
propertyAliases,
|
|
27
|
+
evaluate,
|
|
62
28
|
parseChildren: logicalAnd_1.parseChildren,
|
|
63
29
|
};
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,51 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
13
|
};
|
|
61
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
15
|
exports.CUSTOM_FUNCTIONS = void 0;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
16
|
+
const object_property_extractor_1 = __importDefault(require("object-property-extractor"));
|
|
17
|
+
const _operatorUtils_1 = require("./_operatorUtils");
|
|
18
|
+
const requiredProperties = ['functionPath'];
|
|
19
|
+
const operatorAliases = [
|
|
67
20
|
'customFunctions',
|
|
68
21
|
'customFunction',
|
|
69
22
|
'objectFunctions',
|
|
@@ -71,7 +24,7 @@ var operatorAliases = [
|
|
|
71
24
|
'functions',
|
|
72
25
|
'runFunction',
|
|
73
26
|
];
|
|
74
|
-
|
|
27
|
+
const propertyAliases = {
|
|
75
28
|
functionsPath: 'functionPath',
|
|
76
29
|
functionName: 'functionPath',
|
|
77
30
|
funcName: 'functionPath',
|
|
@@ -79,49 +32,26 @@ var propertyAliases = {
|
|
|
79
32
|
arguments: 'args',
|
|
80
33
|
variables: 'args',
|
|
81
34
|
};
|
|
82
|
-
|
|
83
|
-
var _a,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var args = [];
|
|
98
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
99
|
-
args[_i - 1] = arguments[_i];
|
|
100
|
-
}
|
|
101
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
-
return __generator(this, function (_a) {
|
|
103
|
-
switch (_a.label) {
|
|
104
|
-
case 0: return [4, func.apply(void 0, args)];
|
|
105
|
-
case 1: return [2, _a.sent()];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
functionPath], args, false))];
|
|
111
|
-
case 2:
|
|
112
|
-
result = _h.sent();
|
|
113
|
-
return [2, result];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}); };
|
|
117
|
-
var parseChildren = function (expression) {
|
|
118
|
-
var _a = expression.children, functionPath = _a[0], args = _a.slice(1);
|
|
119
|
-
return __assign(__assign({}, expression), { functionPath: functionPath, args: args });
|
|
35
|
+
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
|
+
const [functionPath, ...args] = (yield (0, _operatorUtils_1.evaluateArray)([expression.functionPath, ...(expression.args || [])], config));
|
|
38
|
+
config.typeChecker({ name: 'functionPath', value: functionPath, expectedType: 'string' });
|
|
39
|
+
const { data, functions } = config.options;
|
|
40
|
+
const func = ((_b = (_a = (0, object_property_extractor_1.default)(functions, functionPath, null)) !== null && _a !== void 0 ? _a : (0, object_property_extractor_1.default)(data, functionPath, null)) !== null && _b !== void 0 ? _b : (0, object_property_extractor_1.default)(config.options, functionPath));
|
|
41
|
+
const shouldUseCache = (_d = (_c = expression.useCache) !== null && _c !== void 0 ? _c : config.options.useCache) !== null && _d !== void 0 ? _d : false;
|
|
42
|
+
const result = yield config.cache.useCache(shouldUseCache, (_, ...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
return yield func(...args);
|
|
44
|
+
}), functionPath, ...args);
|
|
45
|
+
return result;
|
|
46
|
+
});
|
|
47
|
+
const parseChildren = (expression) => {
|
|
48
|
+
const [functionPath, ...args] = expression.children;
|
|
49
|
+
return Object.assign(Object.assign({}, expression), { functionPath, args });
|
|
120
50
|
};
|
|
121
51
|
exports.CUSTOM_FUNCTIONS = {
|
|
122
|
-
requiredProperties
|
|
123
|
-
operatorAliases
|
|
124
|
-
propertyAliases
|
|
125
|
-
evaluate
|
|
126
|
-
parseChildren
|
|
52
|
+
requiredProperties,
|
|
53
|
+
operatorAliases,
|
|
54
|
+
propertyAliases,
|
|
55
|
+
evaluate,
|
|
56
|
+
parseChildren,
|
|
127
57
|
};
|
|
@@ -8,69 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.DIVIDE = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var _a
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return [2, values[0] % values[1]];
|
|
63
|
-
default:
|
|
64
|
-
return [2, values[0] / values[1]];
|
|
65
|
-
}
|
|
66
|
-
return [2];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); };
|
|
13
|
+
const logicalAnd_1 = require("./logicalAnd");
|
|
14
|
+
const _operatorUtils_1 = require("./_operatorUtils");
|
|
15
|
+
const requiredProperties = [];
|
|
16
|
+
const operatorAliases = ['/', 'divide', '÷'];
|
|
17
|
+
const propertyAliases = { divide: 'dividend', by: 'divisor', divideBy: 'divisor' };
|
|
18
|
+
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
var _a;
|
|
20
|
+
const [values, output] = (yield (0, _operatorUtils_1.evaluateArray)([(_a = expression.values) !== null && _a !== void 0 ? _a : [expression.dividend, expression.divisor], expression.output], config));
|
|
21
|
+
config.typeChecker({ name: 'values', value: values, expectedType: 'array' }, { name: 'output', value: output, expectedType: ['string', 'undefined'] });
|
|
22
|
+
if (values.length < 2)
|
|
23
|
+
throw new Error('- Not enough values provided');
|
|
24
|
+
if (!values[1])
|
|
25
|
+
throw new Error('Division by zero!');
|
|
26
|
+
switch (output) {
|
|
27
|
+
case 'quotient':
|
|
28
|
+
return Math.floor(values[0] / values[1]);
|
|
29
|
+
case 'remainder':
|
|
30
|
+
return values[0] % values[1];
|
|
31
|
+
default:
|
|
32
|
+
return values[0] / values[1];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
70
35
|
exports.DIVIDE = {
|
|
71
|
-
requiredProperties
|
|
72
|
-
operatorAliases
|
|
73
|
-
propertyAliases
|
|
74
|
-
evaluate
|
|
36
|
+
requiredProperties,
|
|
37
|
+
operatorAliases,
|
|
38
|
+
propertyAliases,
|
|
39
|
+
evaluate,
|
|
75
40
|
parseChildren: logicalAnd_1.parseChildren,
|
|
76
41
|
};
|
package/build/operators/equal.js
CHANGED
|
@@ -8,65 +8,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.EQUAL = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var _a
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
: false;
|
|
60
|
-
if (nullEqualsUndefined && (values[0] === null || values[0] === undefined))
|
|
61
|
-
return [2, values.every(function (value) { return value === null || value === undefined; })];
|
|
62
|
-
return [2, values.every(function (value) { return (0, lite_1.dequal)(value, values[0]); })];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}); };
|
|
13
|
+
const logicalAnd_1 = require("./logicalAnd");
|
|
14
|
+
const _operatorUtils_1 = require("./_operatorUtils");
|
|
15
|
+
const lite_1 = require("dequal/lite");
|
|
16
|
+
const requiredProperties = ['values'];
|
|
17
|
+
const operatorAliases = ['=', 'eq', 'equal', 'equals'];
|
|
18
|
+
const propertyAliases = {};
|
|
19
|
+
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
var _a;
|
|
21
|
+
const [values, nullMatch] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config));
|
|
22
|
+
config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
|
|
23
|
+
const nullEqualsUndefined = nullMatch !== undefined
|
|
24
|
+
? nullMatch
|
|
25
|
+
: ((_a = config.options) === null || _a === void 0 ? void 0 : _a.nullEqualsUndefined) !== undefined
|
|
26
|
+
? config.options.nullEqualsUndefined
|
|
27
|
+
: false;
|
|
28
|
+
if (nullEqualsUndefined && (values[0] === null || values[0] === undefined))
|
|
29
|
+
return values.every((value) => value === null || value === undefined);
|
|
30
|
+
return values.every((value) => (0, lite_1.dequal)(value, values[0]));
|
|
31
|
+
});
|
|
66
32
|
exports.EQUAL = {
|
|
67
|
-
requiredProperties
|
|
68
|
-
operatorAliases
|
|
69
|
-
propertyAliases
|
|
70
|
-
evaluate
|
|
33
|
+
requiredProperties,
|
|
34
|
+
operatorAliases,
|
|
35
|
+
propertyAliases,
|
|
36
|
+
evaluate,
|
|
71
37
|
parseChildren: logicalAnd_1.parseChildren,
|
|
72
38
|
};
|