pacc 4.9.1 → 4.10.0

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": "4.9.1",
3
+ "version": "4.10.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -50,6 +50,9 @@ export function parse(context) {
50
50
  case OPEN_BRACKET: {
51
51
  const node = expression(0);
52
52
  expect(CLOSE_BRACKET);
53
+ if (typeof node === "number") {
54
+ return { path: [node] };
55
+ }
53
56
  return node;
54
57
  }
55
58
  }
@@ -97,7 +100,7 @@ export function parse(context) {
97
100
  }
98
101
 
99
102
  if (right.token === EOF) {
100
- error("unexpeced EOF");
103
+ error("unexpected EOF");
101
104
  }
102
105
  return {
103
106
  token,
@@ -58,7 +58,27 @@ export function setAttribute(object, expression, value) {
58
58
  * @returns {any} value associated with the given property name
59
59
  */
60
60
  export function getAttribute(object, expression) {
61
- return getAttributeAndOperator(object, expression)[0];
61
+ const { path } = parse({ tokens: tokens(expression) });
62
+
63
+ for (const key of path) {
64
+ if (object !== undefined) {
65
+ switch (typeof object[key]) {
66
+ case "function":
67
+ object = object[key]();
68
+ if (typeof object[Symbol.iterator] === "function") {
69
+ object = [...object];
70
+ }
71
+ break;
72
+ default:
73
+ object = object[key];
74
+ break;
75
+ case "undefined":
76
+ return undefined;
77
+ }
78
+ }
79
+ }
80
+
81
+ return object;
62
82
  }
63
83
 
64
84
  /**