fig-tree-evaluator 2.5.1 → 2.6.0

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 CHANGED
@@ -1510,6 +1510,7 @@ Please open an issue: https://github.com/CarlosNZ/fig-tree-evaluator/issues
1510
1510
 
1511
1511
  *Trivial upgrades (e.g. documentation, small re-factors, types, etc.) not included*
1512
1512
 
1513
+ - **v2.6.0**: Resolve alias nodes that are not part of an Operator node when `evaluateFullObject` is enabled (#78)
1513
1514
  - **v2.5.0**:
1514
1515
  - Bug fixes for edge cases (mainly related to backwards compatibility)
1515
1516
  - More backwards compatibility for very old (pre-v1) syntax (undocumented)
package/build/helpers.js CHANGED
@@ -57,7 +57,7 @@ const isAliasString = (value) => /^\$.+/.test(value);
57
57
  const evaluateNodeAliases = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
58
58
  const aliasKeys = Object.keys(expression).filter(isAliasString);
59
59
  if (aliasKeys.length === 0)
60
- return expression;
60
+ return {};
61
61
  const evaluations = [];
62
62
  aliasKeys.forEach((alias) => evaluations.push((0, evaluate_1.evaluatorFunction)(expression[alias], config)));
63
63
  return (0, _operatorUtils_1.zipArraysToObject)(aliasKeys, yield Promise.all(evaluations));
@@ -116,8 +116,19 @@ const evaluateObject = (input, config) => __awaiter(void 0, void 0, void 0, func
116
116
  if (!(0, exports.isObject)(input))
117
117
  return input;
118
118
  const newObjectEntries = [];
119
- Object.entries(input).forEach(([key, value]) => newObjectEntries.push(key, (0, evaluate_1.evaluatorFunction)(value, config)));
120
- const result = yield Promise.all(newObjectEntries);
121
- return (0, _operatorUtils_1.singleArrayToObject)(result);
119
+ const newAliases = [];
120
+ Object.entries(input).forEach(([key, value]) => {
121
+ if (isAliasString(key)) {
122
+ newAliases.push(key, (0, evaluate_1.evaluatorFunction)(value, config));
123
+ delete input[key];
124
+ }
125
+ });
126
+ const aliasArray = yield Promise.all(newAliases);
127
+ config.resolvedAliasNodes = Object.assign(Object.assign({}, config.resolvedAliasNodes), (0, _operatorUtils_1.singleArrayToObject)(aliasArray));
128
+ Object.entries(input).forEach(([key, value]) => {
129
+ newObjectEntries.push(key, (0, evaluate_1.evaluatorFunction)(value, config));
130
+ });
131
+ const results = yield Promise.all(newObjectEntries);
132
+ return (0, exports.replaceAliasNodeValues)((0, _operatorUtils_1.singleArrayToObject)(results), config);
122
133
  });
123
134
  exports.evaluateObject = evaluateObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fig-tree-evaluator",
3
- "version": "2.5.1",
3
+ "version": "2.6.0",
4
4
  "description": "Module to evaluate JSON-structured expression trees",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",