pacc 2.1.3 → 2.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/README.md CHANGED
@@ -13,6 +13,13 @@
13
13
 
14
14
  propetty path utils
15
15
 
16
+ ```js
17
+ import { getAttribute } from "pacc";
18
+
19
+ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
20
+ // result === 4
21
+ ```
22
+
16
23
  # API
17
24
 
18
25
  <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,11 +25,11 @@
25
25
  "lint:docs": "documentation lint ./src/**/*.mjs"
26
26
  },
27
27
  "devDependencies": {
28
- "ava": "^5.3.1",
29
- "browser-ava": "^2.0.0",
28
+ "ava": "^6.0.1",
29
+ "browser-ava": "^2.1.6",
30
30
  "c8": "^8.0.1",
31
31
  "documentation": "^14.0.2",
32
- "semantic-release": "^22.0.7"
32
+ "semantic-release": "^22.0.12"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
package/src/attribute.mjs CHANGED
@@ -47,15 +47,7 @@ export function setAttribute(object, expression, value) {
47
47
 
48
48
  default:
49
49
  if (anchor) {
50
- switch (typeof token) {
51
- case "number":
52
- object = [];
53
- break;
54
- case "string":
55
- object = {};
56
- break;
57
- }
58
- anchor[anchorKey] = object;
50
+ anchor[anchorKey] = object = (typeof token === "string" ? {} : []);
59
51
  anchor = undefined;
60
52
  }
61
53
 
@@ -83,11 +75,7 @@ export function setAttribute(object, expression, value) {
83
75
  * @returns {any} value associated with the given property name
84
76
  */
85
77
  export function getAttribute(object, expression) {
86
- if (object?.[expression] !== undefined) {
87
- return object[expression];
88
- }
89
-
90
- return getAttributeAndOperator(object, expression)[0];
78
+ return object?.[expression] || getAttributeAndOperator(object, expression)[0];
91
79
  }
92
80
 
93
81
  /**