pacc 4.18.1 → 4.18.3
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 +6 -2
- package/src/expression.mjs +20 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "4.18.
|
|
3
|
+
"version": "4.18.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"description": "property path utils",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"xpath",
|
|
19
|
+
"property path"
|
|
20
|
+
],
|
|
17
21
|
"contributors": [
|
|
18
22
|
{
|
|
19
23
|
"name": "Markus Felten",
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
41
|
"ava": "^6.4.1",
|
|
38
|
-
"browser-ava": "^2.3.
|
|
42
|
+
"browser-ava": "^2.3.32",
|
|
39
43
|
"c8": "^10.1.3",
|
|
40
44
|
"documentation": "^14.0.3",
|
|
41
45
|
"semantic-release": "^24.2.8",
|
package/src/expression.mjs
CHANGED
|
@@ -68,27 +68,26 @@ export function parse(context) {
|
|
|
68
68
|
switch (typeof p) {
|
|
69
69
|
case "string":
|
|
70
70
|
case "number":
|
|
71
|
-
if(typeof result ===
|
|
71
|
+
if (typeof result === "function") {
|
|
72
72
|
const r = [];
|
|
73
|
-
for(const x of result()) {
|
|
73
|
+
for (const x of result()) {
|
|
74
74
|
r.push(x[p]);
|
|
75
75
|
}
|
|
76
76
|
result = r;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
77
|
+
} else {
|
|
79
78
|
result = result[p];
|
|
80
79
|
}
|
|
81
80
|
break;
|
|
82
81
|
case "object":
|
|
82
|
+
const input = result;
|
|
83
83
|
function* filter() {
|
|
84
|
-
for (const x of
|
|
84
|
+
for (const x of input) {
|
|
85
85
|
if (p.eval(p, x)) {
|
|
86
86
|
yield x;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
result = [...filter()];
|
|
90
|
+
result = filter;
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
|
|
@@ -119,9 +118,11 @@ export function parse(context) {
|
|
|
119
118
|
case OPEN_BRACKET: {
|
|
120
119
|
const node = expression(0);
|
|
121
120
|
expect(CLOSE_BRACKET);
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
switch (typeof node) {
|
|
122
|
+
case "number":
|
|
123
|
+
return { eval: pathEval, path: [node] };
|
|
124
124
|
}
|
|
125
|
+
|
|
125
126
|
return node;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
@@ -159,8 +160,8 @@ export function parse(context) {
|
|
|
159
160
|
eval: (node, current) =>
|
|
160
161
|
binop(
|
|
161
162
|
token,
|
|
162
|
-
left
|
|
163
|
-
right
|
|
163
|
+
left.eval ? left.eval(left, current) : left,
|
|
164
|
+
right.eval ? right.eval(right, current) : right,
|
|
164
165
|
binopError
|
|
165
166
|
),
|
|
166
167
|
token,
|
|
@@ -199,8 +200,8 @@ export function parse(context) {
|
|
|
199
200
|
eval: (node, current) =>
|
|
200
201
|
binop(
|
|
201
202
|
token,
|
|
202
|
-
left
|
|
203
|
-
right
|
|
203
|
+
left.eval ? left.eval(left, current) : left,
|
|
204
|
+
right.eval ? right.eval(right, current) : right,
|
|
204
205
|
binopError
|
|
205
206
|
),
|
|
206
207
|
token,
|
|
@@ -238,10 +239,14 @@ export function parse(context) {
|
|
|
238
239
|
|
|
239
240
|
advance();
|
|
240
241
|
|
|
241
|
-
|
|
242
|
+
let result = expression(token.precedence ?? 0);
|
|
242
243
|
|
|
243
244
|
if (context.exec !== false && result?.eval) {
|
|
244
|
-
|
|
245
|
+
result = result.eval(result, context.root);
|
|
246
|
+
|
|
247
|
+
if(typeof result === 'function') {
|
|
248
|
+
return [...result()];
|
|
249
|
+
}
|
|
245
250
|
}
|
|
246
251
|
|
|
247
252
|
return result;
|