simple-graph-query 2.8.1 → 2.8.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.
@@ -49502,25 +49502,21 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
49502
49502
  break;
49503
49503
  case "in":
49504
49504
  case "ni": {
49505
- let membershipResult;
49506
- // this should be true if the left value is equal to the right value,
49507
- // or a subset of it
49508
- if (isTupleArray(leftChildValue) && isTupleArray(rightChildValue)) {
49509
- if (areTupleArraysEqual(leftChildValue, rightChildValue)) {
49510
- membershipResult = true;
49511
- }
49512
- else {
49513
- // check if left is subset of right
49514
- membershipResult = isTupleArraySubset(leftChildValue, rightChildValue);
49515
- }
49516
- }
49517
- else if (isTupleArray(rightChildValue)) {
49518
- membershipResult = rightChildValue.some((tuple) => tuple.length === 1 && tuple[0] === leftChildValue);
49519
- }
49520
- else {
49521
- // left is a tuple array but right is a single value, so false
49522
- membershipResult = false;
49523
- }
49505
+ // In Alloy/Forge everything is a relation, and a scalar is just a
49506
+ // singleton set. Lift any scalar operand to a singleton tuple so `in`
49507
+ // is uniformly subset:
49508
+ // a in b ({a} {b}) -> equality when both are scalars
49509
+ // a in {..} ({a} ⊆ set) -> membership
49510
+ // {..} in b (set ⊆ {b}) -> subset of a singleton
49511
+ // isTupleArraySubset already returns true for equal sets and for an
49512
+ // empty left-hand set, so a single subset check covers every case.
49513
+ const leftSet = isSingleValue(leftChildValue)
49514
+ ? [[leftChildValue]]
49515
+ : leftChildValue;
49516
+ const rightSet = isSingleValue(rightChildValue)
49517
+ ? [[rightChildValue]]
49518
+ : rightChildValue;
49519
+ const membershipResult = isTupleArraySubset(leftSet, rightSet);
49524
49520
  results = ctx.compareOp()?.text === "ni" ? !membershipResult : membershipResult;
49525
49521
  break;
49526
49522
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-graph-query",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "TypeScript evaluator for Forge expressions with browser-compatible UMD bundle",
5
5
  "main": "dist/simple-graph-query.bundle.js",
6
6
  "types": "dist/index.d.ts",