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 +1 -1
- package/src/ast.mjs +7 -5
- package/src/expression.mjs +9 -10
package/package.json
CHANGED
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
|
-
|
|
103
|
-
current
|
|
104
|
-
|
|
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
|
}
|
package/src/expression.mjs
CHANGED
|
@@ -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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
}
|