pacc 8.1.3 → 8.1.5
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 +8 -21
- package/src/expression.mjs +0 -6
package/package.json
CHANGED
package/src/ast.mjs
CHANGED
|
@@ -86,41 +86,28 @@ export function predicateIteratorEval(node, current, context) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export function pathEval(node, current, context) {
|
|
89
|
+
let collection = false;
|
|
89
90
|
for (const item of node.path) {
|
|
90
91
|
switch (typeof item) {
|
|
91
92
|
case "string":
|
|
92
93
|
case "number":
|
|
93
94
|
switch (typeof current) {
|
|
94
|
-
case "function":
|
|
95
|
-
{
|
|
96
|
-
const r = [];
|
|
97
|
-
for (const x of current()) {
|
|
98
|
-
r.push(x[item]);
|
|
99
|
-
}
|
|
100
|
-
current = r;
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
95
|
case "undefined":
|
|
104
96
|
current = context.getGlobal(item);
|
|
105
97
|
break;
|
|
106
98
|
default:
|
|
107
|
-
if (
|
|
108
|
-
current = current.
|
|
99
|
+
if (collection) {
|
|
100
|
+
current = current.map(x => x[item]);
|
|
109
101
|
} else {
|
|
110
|
-
current =
|
|
102
|
+
current =
|
|
103
|
+
(current instanceof Map ? current.get(item) : current[item]) ??
|
|
104
|
+
context.getGlobal(item);
|
|
111
105
|
}
|
|
112
106
|
}
|
|
113
107
|
break;
|
|
114
108
|
case "object":
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
for (const x of r) {
|
|
118
|
-
if (item.eval(item, x, context)) {
|
|
119
|
-
yield x;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
current = filter;
|
|
109
|
+
current = current.filter(c => item.eval(item, c, context));
|
|
110
|
+
collection = true;
|
|
124
111
|
}
|
|
125
112
|
}
|
|
126
113
|
|
package/src/expression.mjs
CHANGED
|
@@ -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;
|