fig-tree-evaluator 2.2.1 → 2.2.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.
Files changed (40) hide show
  1. package/README.md +14 -5
  2. package/build/evaluate.js +138 -50
  3. package/build/helpers.d.ts +1 -0
  4. package/build/helpers.js +131 -45
  5. package/build/index.js +82 -28
  6. package/build/operators/_operatorUtils.js +109 -48
  7. package/build/operators/buildObject.js +84 -26
  8. package/build/operators/conditional.js +70 -18
  9. package/build/operators/count.js +48 -14
  10. package/build/operators/customFunctions.js +76 -21
  11. package/build/operators/divide.js +63 -26
  12. package/build/operators/equal.js +57 -23
  13. package/build/operators/getRequest.js +85 -31
  14. package/build/operators/graphQL.js +90 -40
  15. package/build/operators/greaterThan.js +54 -20
  16. package/build/operators/lessThan.js +54 -20
  17. package/build/operators/logicalAnd.js +61 -16
  18. package/build/operators/logicalOr.js +48 -14
  19. package/build/operators/match.js +101 -38
  20. package/build/operators/multiply.js +48 -14
  21. package/build/operators/notEqual.js +57 -23
  22. package/build/operators/objectProperties.js +66 -21
  23. package/build/operators/passThru.js +58 -15
  24. package/build/operators/pgSQL.js +118 -50
  25. package/build/operators/plus.js +70 -24
  26. package/build/operators/postRequest.js +70 -23
  27. package/build/operators/regex.js +70 -24
  28. package/build/operators/split.js +74 -29
  29. package/build/operators/stringSubstitution.js +79 -25
  30. package/build/operators/subtract.js +50 -16
  31. package/build/typeCheck.js +27 -22
  32. package/build/types.d.ts +1 -0
  33. package/package.json +2 -2
  34. package/build/.DS_Store +0 -0
  35. package/build/FigTreeEvaluator.d.ts +0 -13
  36. package/build/FigTreeEvaluator.js +0 -75
  37. package/build/evaluator.d.ts +0 -13
  38. package/build/evaluator.js +0 -75
  39. package/build/operators/objectFunctions.d.ts +0 -9
  40. package/build/operators/objectFunctions.js +0 -38
@@ -8,28 +8,62 @@ 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
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.LESS_THAN = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const logicalAnd_1 = require("./logicalAnd");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['<', 'lessThan', 'lower', 'smaller'];
17
- const aliasExtensions = [{ '<=': { strict: false } }];
18
- const propertyAliases = {};
19
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
20
- const [values, strict = true] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.strict], config));
21
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
22
- if (values.length < 2)
23
- throw new Error('- Not enough values provided');
24
- const [first, second] = values;
25
- if (first === second && !strict)
26
- return true;
27
- return first < second;
28
- });
40
+ var _operatorUtils_1 = require("./_operatorUtils");
41
+ var logicalAnd_1 = require("./logicalAnd");
42
+ var requiredProperties = ['values'];
43
+ var operatorAliases = ['<', 'lessThan', 'lower', 'smaller'];
44
+ var aliasExtensions = [{ '<=': { strict: false } }];
45
+ var propertyAliases = {};
46
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var _a, values, _b, strict, first, second;
48
+ return __generator(this, function (_c) {
49
+ switch (_c.label) {
50
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.values, expression.strict], config)];
51
+ case 1:
52
+ _a = (_c.sent()), values = _a[0], _b = _a[1], strict = _b === void 0 ? true : _b;
53
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
54
+ if (values.length < 2)
55
+ throw new Error('- Not enough values provided');
56
+ first = values[0], second = values[1];
57
+ if (first === second && !strict)
58
+ return [2, true];
59
+ return [2, first < second];
60
+ }
61
+ });
62
+ }); };
29
63
  exports.LESS_THAN = {
30
- requiredProperties,
31
- operatorAliases,
32
- propertyAliases,
33
- evaluate,
64
+ requiredProperties: requiredProperties,
65
+ operatorAliases: operatorAliases,
66
+ propertyAliases: propertyAliases,
67
+ evaluate: evaluate,
34
68
  parseChildren: logicalAnd_1.parseChildren,
35
69
  };
@@ -1,4 +1,15 @@
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
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,26 +19,60 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
19
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
20
  });
10
21
  };
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
+ };
11
49
  Object.defineProperty(exports, "__esModule", { value: true });
12
50
  exports.AND = exports.parseChildren = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const requiredProperties = ['values'];
15
- const operatorAliases = ['and', '&', '&&'];
16
- const propertyAliases = {};
17
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
- const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
19
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
20
- return values.reduce((acc, val) => acc && !!val, true);
21
- });
22
- const parseChildren = (expression) => {
23
- const values = expression.children;
24
- return Object.assign(Object.assign({}, expression), { values });
51
+ var _operatorUtils_1 = require("./_operatorUtils");
52
+ var requiredProperties = ['values'];
53
+ var operatorAliases = ['and', '&', '&&'];
54
+ var propertyAliases = {};
55
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var values;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)(expression.values, config)];
60
+ case 1:
61
+ values = (_a.sent());
62
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
63
+ return [2, values.reduce(function (acc, val) { return acc && !!val; }, true)];
64
+ }
65
+ });
66
+ }); };
67
+ var parseChildren = function (expression) {
68
+ var values = expression.children;
69
+ return __assign(__assign({}, expression), { values: values });
25
70
  };
26
71
  exports.parseChildren = parseChildren;
27
72
  exports.AND = {
28
- requiredProperties,
29
- operatorAliases,
30
- propertyAliases,
31
- evaluate,
73
+ requiredProperties: requiredProperties,
74
+ operatorAliases: operatorAliases,
75
+ propertyAliases: propertyAliases,
76
+ evaluate: evaluate,
32
77
  parseChildren: exports.parseChildren,
33
78
  };
@@ -8,22 +8,56 @@ 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
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.OR = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['or', '|', '||'];
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.reduce((acc, val) => acc || !!val, false);
22
- });
40
+ var logicalAnd_1 = require("./logicalAnd");
41
+ var _operatorUtils_1 = require("./_operatorUtils");
42
+ var requiredProperties = ['values'];
43
+ var operatorAliases = ['or', '|', '||'];
44
+ var propertyAliases = {};
45
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
46
+ var values;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)(expression.values, config)];
50
+ case 1:
51
+ values = (_a.sent());
52
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
53
+ return [2, values.reduce(function (acc, val) { return acc || !!val; }, false)];
54
+ }
55
+ });
56
+ }); };
23
57
  exports.OR = {
24
- requiredProperties,
25
- operatorAliases,
26
- propertyAliases,
27
- evaluate,
58
+ requiredProperties: requiredProperties,
59
+ operatorAliases: operatorAliases,
60
+ propertyAliases: propertyAliases,
61
+ evaluate: evaluate,
28
62
  parseChildren: logicalAnd_1.parseChildren,
29
63
  };
@@ -1,4 +1,15 @@
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
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,46 +19,98 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
19
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
20
  });
10
21
  };
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
+ };
11
49
  Object.defineProperty(exports, "__esModule", { value: true });
12
50
  exports.MATCH = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const evaluate_1 = require("../evaluate");
15
- const helpers_1 = require("../helpers");
16
- const requiredProperties = ['matchExpression'];
17
- const operatorAliases = ['match', 'switch'];
18
- const propertyAliases = { arms: 'branches', cases: 'branches', match: 'matchExpression' };
19
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
20
- const matchExpression = (yield (0, evaluate_1.evaluatorFunction)(expression.matchExpression, config));
21
- const branches = expression.branches;
22
- config.typeChecker({
23
- name: 'matchExpression',
24
- value: matchExpression,
25
- expectedType: ['string', 'number', 'boolean'],
26
- }, {
27
- name: 'branches',
28
- value: branches,
29
- expectedType: ['object', 'array', 'undefined'],
51
+ var _operatorUtils_1 = require("./_operatorUtils");
52
+ var evaluate_1 = require("../evaluate");
53
+ var helpers_1 = require("../helpers");
54
+ var requiredProperties = ['matchExpression'];
55
+ var operatorAliases = ['match', 'switch'];
56
+ var propertyAliases = { arms: 'branches', cases: 'branches', match: 'matchExpression' };
57
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
58
+ var matchExpression, branches, branchObject;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0: return [4, (0, evaluate_1.evaluatorFunction)(expression.matchExpression, config)];
62
+ case 1:
63
+ matchExpression = (_a.sent());
64
+ branches = expression.branches;
65
+ config.typeChecker({
66
+ name: 'matchExpression',
67
+ value: matchExpression,
68
+ expectedType: ['string', 'number', 'boolean'],
69
+ }, {
70
+ name: 'branches',
71
+ value: branches,
72
+ expectedType: ['object', 'array', 'undefined'],
73
+ });
74
+ branchObject = Array.isArray(branches) ? (0, _operatorUtils_1.singleArrayToObject)(branches) : branches !== null && branches !== void 0 ? branches : {};
75
+ if (!(0, helpers_1.isOperatorNode)(branchObject)) return [3, 3];
76
+ return [4, (0, evaluate_1.evaluatorFunction)(branchObject, config)];
77
+ case 2:
78
+ branchObject = _a.sent();
79
+ _a.label = 3;
80
+ case 3:
81
+ if (!(matchExpression in branchObject)) return [3, 5];
82
+ return [4, (0, evaluate_1.evaluatorFunction)(branchObject[matchExpression], config)];
83
+ case 4: return [2, _a.sent()];
84
+ case 5:
85
+ if (!('fallback' in branchObject)) return [3, 7];
86
+ return [4, (0, evaluate_1.evaluatorFunction)(branchObject.fallback, config)];
87
+ case 6: return [2, _a.sent()];
88
+ case 7:
89
+ if (!(matchExpression in expression)) return [3, 9];
90
+ return [4, (0, evaluate_1.evaluatorFunction)(expression[matchExpression], config)];
91
+ case 8: return [2, _a.sent()];
92
+ case 9: throw new Error("No match found for ".concat(matchExpression));
93
+ }
94
+ });
95
+ }); };
96
+ var parseChildren = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
97
+ var _a, matchExpression, elements, branches, _b;
98
+ return __generator(this, function (_c) {
99
+ switch (_c.label) {
100
+ case 0:
101
+ _a = expression.children, matchExpression = _a[0], elements = _a.slice(1);
102
+ _b = _operatorUtils_1.singleArrayToObject;
103
+ return [4, (0, _operatorUtils_1.evaluateArray)(elements, config)];
104
+ case 1:
105
+ branches = _b.apply(void 0, [_c.sent()]);
106
+ return [2, __assign(__assign({}, expression), { matchExpression: matchExpression, branches: branches })];
107
+ }
30
108
  });
31
- let branchObject = Array.isArray(branches) ? (0, _operatorUtils_1.singleArrayToObject)(branches) : branches !== null && branches !== void 0 ? branches : {};
32
- if ((0, helpers_1.isOperatorNode)(branchObject))
33
- branchObject = yield (0, evaluate_1.evaluatorFunction)(branchObject, config);
34
- if (matchExpression in branchObject)
35
- return yield (0, evaluate_1.evaluatorFunction)(branchObject[matchExpression], config);
36
- if ('fallback' in branchObject)
37
- return yield (0, evaluate_1.evaluatorFunction)(branchObject.fallback, config);
38
- if (matchExpression in expression)
39
- return yield (0, evaluate_1.evaluatorFunction)(expression[matchExpression], config);
40
- throw new Error(`No match found for ${matchExpression}`);
41
- });
42
- const parseChildren = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
43
- const [matchExpression, ...elements] = expression.children;
44
- const branches = (0, _operatorUtils_1.singleArrayToObject)(yield (0, _operatorUtils_1.evaluateArray)(elements, config));
45
- return Object.assign(Object.assign({}, expression), { matchExpression, branches });
46
- });
109
+ }); };
47
110
  exports.MATCH = {
48
- requiredProperties,
49
- operatorAliases,
50
- propertyAliases,
51
- evaluate,
52
- parseChildren,
111
+ requiredProperties: requiredProperties,
112
+ operatorAliases: operatorAliases,
113
+ propertyAliases: propertyAliases,
114
+ evaluate: evaluate,
115
+ parseChildren: parseChildren,
53
116
  };
@@ -8,22 +8,56 @@ 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
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.MULTIPLY = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['*', 'x', 'multiply', 'times'];
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.reduce((acc, number) => acc * number);
22
- });
40
+ var logicalAnd_1 = require("./logicalAnd");
41
+ var _operatorUtils_1 = require("./_operatorUtils");
42
+ var requiredProperties = ['values'];
43
+ var operatorAliases = ['*', 'x', 'multiply', 'times'];
44
+ var propertyAliases = {};
45
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
46
+ var values;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)(expression.values, config)];
50
+ case 1:
51
+ values = (_a.sent());
52
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
53
+ return [2, values.reduce(function (acc, number) { return acc * number; })];
54
+ }
55
+ });
56
+ }); };
23
57
  exports.MULTIPLY = {
24
- requiredProperties,
25
- operatorAliases,
26
- propertyAliases,
27
- evaluate,
58
+ requiredProperties: requiredProperties,
59
+ operatorAliases: operatorAliases,
60
+ propertyAliases: propertyAliases,
61
+ evaluate: evaluate,
28
62
  parseChildren: logicalAnd_1.parseChildren,
29
63
  };
@@ -8,31 +8,65 @@ 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
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.NOT_EQUAL = void 0;
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 = ['!=', '!', 'ne', 'notEqual'];
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.some((value) => value === null && value === undefined);
30
- return values.some((val) => !(0, lite_1.dequal)(val, values[0]));
31
- });
40
+ var logicalAnd_1 = require("./logicalAnd");
41
+ var _operatorUtils_1 = require("./_operatorUtils");
42
+ var lite_1 = require("dequal/lite");
43
+ var requiredProperties = ['values'];
44
+ var operatorAliases = ['!=', '!', 'ne', 'notEqual'];
45
+ var propertyAliases = {};
46
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var _a, values, nullMatch, nullEqualsUndefined;
48
+ var _b;
49
+ return __generator(this, function (_c) {
50
+ switch (_c.label) {
51
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config)];
52
+ case 1:
53
+ _a = (_c.sent()), values = _a[0], nullMatch = _a[1];
54
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
55
+ nullEqualsUndefined = nullMatch !== undefined
56
+ ? nullMatch
57
+ : ((_b = config.options) === null || _b === void 0 ? void 0 : _b.nullEqualsUndefined) !== undefined
58
+ ? config.options.nullEqualsUndefined
59
+ : false;
60
+ if (nullEqualsUndefined && (values[0] === null || values[0] === undefined))
61
+ return [2, values.some(function (value) { return value === null && value === undefined; })];
62
+ return [2, values.some(function (val) { return !(0, lite_1.dequal)(val, values[0]); })];
63
+ }
64
+ });
65
+ }); };
32
66
  exports.NOT_EQUAL = {
33
- requiredProperties,
34
- operatorAliases,
35
- propertyAliases,
36
- evaluate,
67
+ requiredProperties: requiredProperties,
68
+ operatorAliases: operatorAliases,
69
+ propertyAliases: propertyAliases,
70
+ evaluate: evaluate,
37
71
  parseChildren: logicalAnd_1.parseChildren,
38
72
  };