pacc 8.1.4 → 8.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "8.1.4",
3
+ "version": "8.1.6",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
package/src/ast.mjs CHANGED
@@ -99,15 +99,17 @@ export function pathEval(node, current, context) {
99
99
  if (collection) {
100
100
  current = current.map(x => x[item]);
101
101
  } else {
102
- if (current instanceof Map) {
103
- current = current.get(item);
104
- } else {
105
- current = current[item] ?? context.getGlobal(item);
106
- }
102
+ current =
103
+ (current instanceof Map ? current.get(item) : current[item]) ??
104
+ context.getGlobal(item);
107
105
  }
108
106
  }
109
107
  break;
110
108
  case "object":
109
+ if (current.values) {
110
+ current = current.values();
111
+ }
112
+
111
113
  current = current.filter(c => item.eval(item, c, context));
112
114
  collection = true;
113
115
  }
@@ -64,7 +64,7 @@ export function parse(input, context = {}) {
64
64
  return node;
65
65
  }
66
66
  case OPEN_BRACKET: {
67
- if(token === CLOSE_BRACKET) {
67
+ if (token === CLOSE_BRACKET) {
68
68
  advance();
69
69
  return ASTNodeTrue;
70
70
  }
@@ -135,12 +135,6 @@ export function parse(input, context = {}) {
135
135
  }
136
136
  }
137
137
  if (last === DOT) {
138
- switch (typeof left) {
139
- case "number":
140
- right.path.unshift(left);
141
- return right;
142
- }
143
-
144
138
  if (left.path) {
145
139
  left.path.push(...right.path);
146
140
  return left;
@@ -186,9 +180,14 @@ export function parse(input, context = {}) {
186
180
  return left;
187
181
  }
188
182
  case OPEN_BRACKET: {
189
- const predicate = expression(0);
190
- expect(CLOSE_BRACKET);
191
- left.path.push(predicate);
183
+ if (token === CLOSE_BRACKET) {
184
+ advance();
185
+ left.path.push(ASTNodeTrue);
186
+ } else {
187
+ const predicate = expression(0);
188
+ expect(CLOSE_BRACKET);
189
+ left.path.push(predicate);
190
+ }
192
191
  return left;
193
192
  }
194
193
  }