@almadar/evaluator 2.9.2 → 2.10.1
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/dist/index.d.ts +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2573,12 +2573,22 @@ var SExpressionEvaluator = class {
|
|
|
2573
2573
|
if (isBinding(expr)) {
|
|
2574
2574
|
return resolveBinding(expr, ctx);
|
|
2575
2575
|
}
|
|
2576
|
+
if (this.isPlainObject(expr)) {
|
|
2577
|
+
const out = {};
|
|
2578
|
+
for (const [k, v] of Object.entries(expr)) {
|
|
2579
|
+
out[k] = this.evaluate(v, ctx);
|
|
2580
|
+
}
|
|
2581
|
+
return out;
|
|
2582
|
+
}
|
|
2576
2583
|
return expr;
|
|
2577
2584
|
}
|
|
2578
2585
|
const op = getOperator(expr);
|
|
2579
2586
|
const args = getArgs(expr);
|
|
2580
2587
|
return this.dispatchOperator(op, args, ctx);
|
|
2581
2588
|
}
|
|
2589
|
+
isPlainObject(value) {
|
|
2590
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && Object.getPrototypeOf(value) === Object.prototype;
|
|
2591
|
+
}
|
|
2582
2592
|
/**
|
|
2583
2593
|
* Evaluate an S-expression as a guard (returns boolean).
|
|
2584
2594
|
*
|