pacc 2.1.4 → 3.0.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2023 by pacc
1
+ Copyright (c) 2023-2024 by pacc
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -13,7 +13,6 @@
13
13
 
14
14
  propetty path utils
15
15
 
16
-
17
16
  ```js
18
17
  import { getAttribute } from "pacc";
19
18
 
@@ -27,21 +26,16 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
27
26
 
28
27
  ### Table of Contents
29
28
 
30
- - [pacc](#pacc)
31
- - [API](#api)
32
- - [Table of Contents](#table-of-contents)
33
- - [AttributeDefinition](#attributedefinition)
34
- - [Properties](#properties)
35
- - [setAttribute](#setattribute)
36
- - [Parameters](#parameters)
37
- - [getAttribute](#getattribute)
38
- - [Parameters](#parameters-1)
39
- - [getAttributeAndOperator](#getattributeandoperator)
40
- - [Parameters](#parameters-2)
41
- - [tokens](#tokens)
42
- - [Parameters](#parameters-3)
43
- - [install](#install)
44
- - [license](#license)
29
+ * [AttributeDefinition](#attributedefinition)
30
+ * [Properties](#properties)
31
+ * [setAttribute](#setattribute)
32
+ * [Parameters](#parameters)
33
+ * [getAttribute](#getattribute)
34
+ * [Parameters](#parameters-1)
35
+ * [getAttributeAndOperator](#getattributeandoperator)
36
+ * [Parameters](#parameters-2)
37
+ * [tokens](#tokens)
38
+ * [Parameters](#parameters-3)
45
39
 
46
40
  ## AttributeDefinition
47
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "2.1.4",
3
+ "version": "3.0.0",
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.1.0",
30
- "c8": "^8.0.1",
31
- "documentation": "^14.0.2",
32
- "semantic-release": "^22.0.7"
28
+ "ava": "^6.1.1",
29
+ "browser-ava": "^2.1.9",
30
+ "c8": "^9.1.0",
31
+ "documentation": "^14.0.3",
32
+ "semantic-release": "^23.0.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
package/src/attribute.mjs CHANGED
@@ -47,7 +47,7 @@ export function setAttribute(object, expression, value) {
47
47
 
48
48
  default:
49
49
  if (anchor) {
50
- anchor[anchorKey] = object = (typeof token === "string" ? {} : []);
50
+ anchor[anchorKey] = object = typeof token === "string" ? {} : [];
51
51
  anchor = undefined;
52
52
  }
53
53
 
@@ -75,11 +75,7 @@ export function setAttribute(object, expression, value) {
75
75
  * @returns {any} value associated with the given property name
76
76
  */
77
77
  export function getAttribute(object, expression) {
78
- if (object?.[expression] !== undefined) {
79
- return object[expression];
80
- }
81
-
82
- return getAttributeAndOperator(object, expression)[0];
78
+ return object?.[expression] || getAttributeAndOperator(object, expression)[0];
83
79
  }
84
80
 
85
81
  /**
@@ -89,7 +85,7 @@ export function getAttribute(object, expression) {
89
85
  * @param {string} expression
90
86
  * @returns {[any,string]} value associated with the given property name
91
87
  */
92
- export function getAttributeAndOperator(object, expression, getters = {}) {
88
+ export function getAttributeAndOperator(object, expression) {
93
89
  let op = EQUAL;
94
90
  let predicateTokens;
95
91
 
@@ -124,15 +120,10 @@ export function getAttributeAndOperator(object, expression, getters = {}) {
124
120
  break;
125
121
  }
126
122
 
127
- const g = getters[token];
128
- if (g) {
129
- object = g(object);
123
+ if (object[token] !== undefined) {
124
+ object = object[token];
130
125
  } else {
131
- if (object[token] !== undefined) {
132
- object = object[token];
133
- } else {
134
- return [undefined, op];
135
- }
126
+ return [undefined, op];
136
127
  }
137
128
  }
138
129
  }
package/src/tokens.mjs CHANGED
@@ -217,11 +217,11 @@ export function* tokens(string) {
217
217
  default:
218
218
  yield lookup[state];
219
219
  case undefined:
220
- buffer = c.charCodeAt(0) - "0".charCodeAt(0);
220
+ buffer = c.charCodeAt(0) - 48;
221
221
  state = "number";
222
222
  break;
223
223
  case "number":
224
- buffer = buffer * 10 + c.charCodeAt(0) - "0".charCodeAt(0);
224
+ buffer = buffer * 10 + c.charCodeAt(0) - 48;
225
225
  break;
226
226
  case "string":
227
227
  case "identifier":