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.
@@ -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.OR = void 0;
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
- }); };
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
+ });
57
23
  exports.OR = {
58
- requiredProperties: requiredProperties,
59
- operatorAliases: operatorAliases,
60
- propertyAliases: propertyAliases,
61
- evaluate: 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,98 +8,46 @@ 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.MATCH = void 0;
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
- }
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'],
108
30
  });
109
- }); };
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
+ });
110
47
  exports.MATCH = {
111
- requiredProperties: requiredProperties,
112
- operatorAliases: operatorAliases,
113
- propertyAliases: propertyAliases,
114
- evaluate: evaluate,
115
- parseChildren: parseChildren,
48
+ requiredProperties,
49
+ operatorAliases,
50
+ propertyAliases,
51
+ evaluate,
52
+ parseChildren,
116
53
  };
@@ -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.MULTIPLY = void 0;
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
- }); };
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
+ });
57
23
  exports.MULTIPLY = {
58
- requiredProperties: requiredProperties,
59
- operatorAliases: operatorAliases,
60
- propertyAliases: propertyAliases,
61
- evaluate: evaluate,
24
+ requiredProperties,
25
+ operatorAliases,
26
+ propertyAliases,
27
+ evaluate,
62
28
  parseChildren: logicalAnd_1.parseChildren,
63
29
  };
@@ -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.NOT_EQUAL = void 0;
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
- }); };
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
+ });
66
32
  exports.NOT_EQUAL = {
67
- requiredProperties: requiredProperties,
68
- operatorAliases: operatorAliases,
69
- propertyAliases: propertyAliases,
70
- evaluate: evaluate,
33
+ requiredProperties,
34
+ operatorAliases,
35
+ propertyAliases,
36
+ evaluate,
71
37
  parseChildren: logicalAnd_1.parseChildren,
72
38
  };
@@ -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,42 +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
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
13
  };
52
14
  Object.defineProperty(exports, "__esModule", { value: true });
53
15
  exports.OBJECT_PROPERTIES = void 0;
54
- var object_property_extractor_1 = __importDefault(require("object-property-extractor"));
55
- var _operatorUtils_1 = require("./_operatorUtils");
56
- var requiredProperties = ['property'];
57
- var operatorAliases = [
16
+ const object_property_extractor_1 = __importDefault(require("object-property-extractor"));
17
+ const _operatorUtils_1 = require("./_operatorUtils");
18
+ const requiredProperties = ['property'];
19
+ const operatorAliases = [
58
20
  'dataProperties',
59
21
  'data',
60
22
  'getData',
@@ -63,7 +25,7 @@ var operatorAliases = [
63
25
  'getProperty',
64
26
  'getObjProp',
65
27
  ];
66
- var propertyAliases = {
28
+ const propertyAliases = {
67
29
  path: 'property',
68
30
  propertyName: 'property',
69
31
  additional: 'additionalData',
@@ -71,29 +33,22 @@ var propertyAliases = {
71
33
  data: 'additionalData',
72
34
  additionalObjects: 'additionalData',
73
35
  };
74
- var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
75
- var _a, property, additionalData, inputObject;
76
- var _b, _c, _d, _e;
77
- return __generator(this, function (_f) {
78
- switch (_f.label) {
79
- case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.property, expression.additionalData], config)];
80
- case 1:
81
- _a = (_f.sent()), property = _a[0], additionalData = _a[1];
82
- config.typeChecker({ name: 'property', value: property, expectedType: 'string' }, { name: 'additionalData', value: additionalData, expectedType: ['object', 'undefined'] });
83
- inputObject = additionalData
84
- ? __assign(__assign({}, ((_c = (_b = config.options) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : {})), additionalData) : (_e = (_d = config.options) === null || _d === void 0 ? void 0 : _d.data) !== null && _e !== void 0 ? _e : {};
85
- return [2, (0, object_property_extractor_1.default)(inputObject, property)];
86
- }
87
- });
88
- }); };
89
- var parseChildren = function (expression) {
90
- var _a = expression.children, property = _a[0], fallback = _a[1];
91
- return __assign(__assign({}, expression), { property: property, fallback: fallback });
36
+ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
37
+ var _a, _b, _c, _d;
38
+ const [property, additionalData] = (yield (0, _operatorUtils_1.evaluateArray)([expression.property, expression.additionalData], config));
39
+ config.typeChecker({ name: 'property', value: property, expectedType: 'string' }, { name: 'additionalData', value: additionalData, expectedType: ['object', 'undefined'] });
40
+ const inputObject = additionalData
41
+ ? Object.assign(Object.assign({}, ((_b = (_a = config.options) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {})), additionalData) : (_d = (_c = config.options) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : {};
42
+ return (0, object_property_extractor_1.default)(inputObject, property);
43
+ });
44
+ const parseChildren = (expression) => {
45
+ const [property, fallback] = expression.children;
46
+ return Object.assign(Object.assign({}, expression), { property, fallback });
92
47
  };
93
48
  exports.OBJECT_PROPERTIES = {
94
- requiredProperties: requiredProperties,
95
- operatorAliases: operatorAliases,
96
- propertyAliases: propertyAliases,
97
- evaluate: evaluate,
98
- parseChildren: parseChildren,
49
+ requiredProperties,
50
+ operatorAliases,
51
+ propertyAliases,
52
+ evaluate,
53
+ parseChildren,
99
54
  };
@@ -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,55 +8,23 @@ 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.PASSTHRU = void 0;
51
- var evaluate_1 = require("../evaluate");
52
- var requiredProperties = ['value'];
53
- var operatorAliases = ['_', 'passThru', 'pass', 'ignore', 'coerce', 'convert'];
54
- var propertyAliases = { _: 'value', data: 'value' };
55
- var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
58
- case 0: return [4, (0, evaluate_1.evaluatorFunction)(expression.value, config)];
59
- case 1: return [2, _a.sent()];
60
- }
61
- });
62
- }); };
63
- var parseChildren = function (expression) {
64
- var children = expression.children.slice(0);
65
- return __assign(__assign({}, expression), { value: children });
13
+ const evaluate_1 = require("../evaluate");
14
+ const requiredProperties = ['value'];
15
+ const operatorAliases = ['_', 'passThru', 'pass', 'ignore', 'coerce', 'convert'];
16
+ const propertyAliases = { _: 'value', data: 'value' };
17
+ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
+ return yield (0, evaluate_1.evaluatorFunction)(expression.value, config);
19
+ });
20
+ const parseChildren = (expression) => {
21
+ const [...children] = expression.children;
22
+ return Object.assign(Object.assign({}, expression), { value: children });
66
23
  };
67
24
  exports.PASSTHRU = {
68
- requiredProperties: requiredProperties,
69
- operatorAliases: operatorAliases,
70
- propertyAliases: propertyAliases,
71
- evaluate: evaluate,
72
- parseChildren: parseChildren,
25
+ requiredProperties,
26
+ operatorAliases,
27
+ propertyAliases,
28
+ evaluate,
29
+ parseChildren,
73
30
  };