pacc 4.18.2 → 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.
Files changed (2) hide show
  1. package/package.json +6 -2
  2. package/src/expression.mjs +16 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "4.18.2",
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.31",
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",
@@ -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 === 'function') {
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 result) {
84
+ for (const x of input) {
85
85
  if (p.eval(p, x)) {
86
86
  yield x;
87
87
  }
88
88
  }
89
89
  }
90
- //result = filter;
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
- if (typeof node === "number") {
123
- return { eval: pathEval, path: [node] };
121
+ switch (typeof node) {
122
+ case "number":
123
+ return { eval: pathEval, path: [node] };
124
124
  }
125
+
125
126
  return node;
126
127
  }
127
128
  }
@@ -238,10 +239,14 @@ export function parse(context) {
238
239
 
239
240
  advance();
240
241
 
241
- const result = expression(token.precedence ?? 0);
242
+ let result = expression(token.precedence ?? 0);
242
243
 
243
244
  if (context.exec !== false && result?.eval) {
244
- return result.eval(result, context.root);
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;