pacc 3.1.6 → 3.1.8
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 +153 -24
- package/package.json +6 -6
- package/src/attribute.mjs +6 -0
- package/src/tokens.mjs +11 -3
package/README.md
CHANGED
|
@@ -29,20 +29,46 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
|
|
|
29
29
|
|
|
30
30
|
* [AttributeDefinition](#attributedefinition)
|
|
31
31
|
* [Properties](#properties)
|
|
32
|
-
* [
|
|
33
|
-
|
|
34
|
-
* [Token](#token-1)
|
|
35
|
-
* [Properties](#properties-2)
|
|
36
|
-
* [setAttribute](#setattribute)
|
|
32
|
+
* [tokens](#tokens)
|
|
33
|
+
* [tokens](#tokens-1)
|
|
37
34
|
* [Parameters](#parameters)
|
|
38
|
-
* [
|
|
35
|
+
* [setAttribute](#setattribute)
|
|
39
36
|
* [Parameters](#parameters-1)
|
|
40
|
-
* [
|
|
37
|
+
* [getAttribute](#getattribute)
|
|
41
38
|
* [Parameters](#parameters-2)
|
|
42
|
-
* [
|
|
39
|
+
* [getAttributeAndOperator](#getattributeandoperator)
|
|
43
40
|
* [Parameters](#parameters-3)
|
|
44
|
-
* [
|
|
41
|
+
* [lookup](#lookup)
|
|
42
|
+
* [Token](#token)
|
|
43
|
+
* [Properties](#properties-1)
|
|
44
|
+
* [createToken](#createtoken)
|
|
45
45
|
* [Parameters](#parameters-4)
|
|
46
|
+
* [PLUS](#plus)
|
|
47
|
+
* [MINUS](#minus)
|
|
48
|
+
* [STAR](#star)
|
|
49
|
+
* [DIVIDE](#divide)
|
|
50
|
+
* [NOT](#not)
|
|
51
|
+
* [NOT\_EQUAL](#not_equal)
|
|
52
|
+
* [GREATER](#greater)
|
|
53
|
+
* [GREATER\_EQUAL](#greater_equal)
|
|
54
|
+
* [LESS](#less)
|
|
55
|
+
* [LESS\_EQUAL](#less_equal)
|
|
56
|
+
* [EQUAL](#equal)
|
|
57
|
+
* [OPEN\_ROUND](#open_round)
|
|
58
|
+
* [CLOSE\_ROUND](#close_round)
|
|
59
|
+
* [OPEN\_BRACKET](#open_bracket)
|
|
60
|
+
* [CLOSE\_BRACKET](#close_bracket)
|
|
61
|
+
* [OPEN\_CURLY](#open_curly)
|
|
62
|
+
* [CLOSE\_CURLY](#close_curly)
|
|
63
|
+
* [QUESTION](#question)
|
|
64
|
+
* [COLON](#colon)
|
|
65
|
+
* [SEMICOLON](#semicolon)
|
|
66
|
+
* [COMMA](#comma)
|
|
67
|
+
* [DOT](#dot)
|
|
68
|
+
* [AMPERSAND](#ampersand)
|
|
69
|
+
* [DOUBLE\_AMPERSAND](#double_ampersand)
|
|
70
|
+
* [BAR](#bar)
|
|
71
|
+
* [DOUBLE\_BAR](#double_bar)
|
|
46
72
|
|
|
47
73
|
## AttributeDefinition
|
|
48
74
|
|
|
@@ -57,26 +83,21 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
57
83
|
* `private` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** should the value be shown
|
|
58
84
|
* `depends` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** name of an attribute we depend on
|
|
59
85
|
* `additionalAttributes` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** extra attributes that are present in case our attribute is set
|
|
86
|
+
* `description` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** human readable
|
|
60
87
|
* `default` **any?** the default value
|
|
61
88
|
* `set` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** set the value
|
|
62
89
|
* `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
|
|
63
90
|
* `env` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** environment variable(s) used to provide the value
|
|
64
91
|
|
|
65
|
-
##
|
|
66
|
-
|
|
67
|
-
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
|
|
68
|
-
|
|
69
|
-
### Properties
|
|
70
|
-
|
|
71
|
-
* `str` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
92
|
+
## tokens
|
|
72
93
|
|
|
73
|
-
##
|
|
94
|
+
## tokens
|
|
74
95
|
|
|
75
|
-
|
|
96
|
+
Split property path into tokens
|
|
76
97
|
|
|
77
|
-
###
|
|
98
|
+
### Parameters
|
|
78
99
|
|
|
79
|
-
* `
|
|
100
|
+
* `string` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
80
101
|
|
|
81
102
|
## setAttribute
|
|
82
103
|
|
|
@@ -113,6 +134,18 @@ The name may be a property path like 'a.b.c <='.
|
|
|
113
134
|
|
|
114
135
|
Returns **\[any, [Token](#token)]** value associated with the given property name
|
|
115
136
|
|
|
137
|
+
## lookup
|
|
138
|
+
|
|
139
|
+
Token lookup
|
|
140
|
+
|
|
141
|
+
## Token
|
|
142
|
+
|
|
143
|
+
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
|
|
144
|
+
|
|
145
|
+
### Properties
|
|
146
|
+
|
|
147
|
+
* `str` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
148
|
+
|
|
116
149
|
## createToken
|
|
117
150
|
|
|
118
151
|
### Parameters
|
|
@@ -121,13 +154,109 @@ Returns **\[any, [Token](#token)]** value associated with the given property nam
|
|
|
121
154
|
|
|
122
155
|
Returns **[Token](#token)** 
|
|
123
156
|
|
|
124
|
-
##
|
|
157
|
+
## PLUS
|
|
125
158
|
|
|
126
|
-
|
|
159
|
+
Type: [Token](#token)
|
|
127
160
|
|
|
128
|
-
|
|
161
|
+
## MINUS
|
|
129
162
|
|
|
130
|
-
|
|
163
|
+
Type: [Token](#token)
|
|
164
|
+
|
|
165
|
+
## STAR
|
|
166
|
+
|
|
167
|
+
Type: [Token](#token)
|
|
168
|
+
|
|
169
|
+
## DIVIDE
|
|
170
|
+
|
|
171
|
+
Type: [Token](#token)
|
|
172
|
+
|
|
173
|
+
## NOT
|
|
174
|
+
|
|
175
|
+
Type: [Token](#token)
|
|
176
|
+
|
|
177
|
+
## NOT\_EQUAL
|
|
178
|
+
|
|
179
|
+
Type: [Token](#token)
|
|
180
|
+
|
|
181
|
+
## GREATER
|
|
182
|
+
|
|
183
|
+
Type: [Token](#token)
|
|
184
|
+
|
|
185
|
+
## GREATER\_EQUAL
|
|
186
|
+
|
|
187
|
+
Type: [Token](#token)
|
|
188
|
+
|
|
189
|
+
## LESS
|
|
190
|
+
|
|
191
|
+
Type: [Token](#token)
|
|
192
|
+
|
|
193
|
+
## LESS\_EQUAL
|
|
194
|
+
|
|
195
|
+
Type: [Token](#token)
|
|
196
|
+
|
|
197
|
+
## EQUAL
|
|
198
|
+
|
|
199
|
+
Type: [Token](#token)
|
|
200
|
+
|
|
201
|
+
## OPEN\_ROUND
|
|
202
|
+
|
|
203
|
+
Type: [Token](#token)
|
|
204
|
+
|
|
205
|
+
## CLOSE\_ROUND
|
|
206
|
+
|
|
207
|
+
Type: [Token](#token)
|
|
208
|
+
|
|
209
|
+
## OPEN\_BRACKET
|
|
210
|
+
|
|
211
|
+
Type: [Token](#token)
|
|
212
|
+
|
|
213
|
+
## CLOSE\_BRACKET
|
|
214
|
+
|
|
215
|
+
Type: [Token](#token)
|
|
216
|
+
|
|
217
|
+
## OPEN\_CURLY
|
|
218
|
+
|
|
219
|
+
Type: [Token](#token)
|
|
220
|
+
|
|
221
|
+
## CLOSE\_CURLY
|
|
222
|
+
|
|
223
|
+
Type: [Token](#token)
|
|
224
|
+
|
|
225
|
+
## QUESTION
|
|
226
|
+
|
|
227
|
+
Type: [Token](#token)
|
|
228
|
+
|
|
229
|
+
## COLON
|
|
230
|
+
|
|
231
|
+
Type: [Token](#token)
|
|
232
|
+
|
|
233
|
+
## SEMICOLON
|
|
234
|
+
|
|
235
|
+
Type: [Token](#token)
|
|
236
|
+
|
|
237
|
+
## COMMA
|
|
238
|
+
|
|
239
|
+
Type: [Token](#token)
|
|
240
|
+
|
|
241
|
+
## DOT
|
|
242
|
+
|
|
243
|
+
Type: [Token](#token)
|
|
244
|
+
|
|
245
|
+
## AMPERSAND
|
|
246
|
+
|
|
247
|
+
Type: [Token](#token)
|
|
248
|
+
|
|
249
|
+
## DOUBLE\_AMPERSAND
|
|
250
|
+
|
|
251
|
+
Type: [Token](#token)
|
|
252
|
+
|
|
253
|
+
## BAR
|
|
254
|
+
|
|
255
|
+
Type: [Token](#token)
|
|
256
|
+
|
|
257
|
+
## DOUBLE\_BAR
|
|
258
|
+
|
|
259
|
+
Type: [Token](#token)
|
|
131
260
|
|
|
132
261
|
# install
|
|
133
262
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"ava": "^6.1.
|
|
37
|
-
"browser-ava": "^2.2.
|
|
36
|
+
"ava": "^6.1.3",
|
|
37
|
+
"browser-ava": "^2.2.15",
|
|
38
38
|
"c8": "^9.1.0",
|
|
39
39
|
"documentation": "^14.0.3",
|
|
40
|
-
"semantic-release": "^
|
|
41
|
-
"typescript": "^5.4.
|
|
40
|
+
"semantic-release": "^24.0.0",
|
|
41
|
+
"typescript": "^5.4.5"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": ">=20.
|
|
44
|
+
"node": ">=20.14.0"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
package/src/attribute.mjs
CHANGED
|
@@ -118,6 +118,12 @@ export function getAttributeAndOperator(object, expression) {
|
|
|
118
118
|
predicateTokens = undefined;
|
|
119
119
|
break;
|
|
120
120
|
case STAR:
|
|
121
|
+
if(!predicateTokens) {
|
|
122
|
+
const error = new Error("unexpected '*' in attribute path");
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
error.expression = expression;
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
121
127
|
predicateTokens.push(token);
|
|
122
128
|
break;
|
|
123
129
|
|
package/src/tokens.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token lookup
|
|
3
|
+
*/
|
|
1
4
|
const lookup = {};
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -6,8 +9,8 @@ const lookup = {};
|
|
|
6
9
|
*/
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {string} str
|
|
12
|
+
*
|
|
13
|
+
* @param {string} str
|
|
11
14
|
* @returns {Token}
|
|
12
15
|
*/
|
|
13
16
|
function createToken(str) {
|
|
@@ -56,7 +59,9 @@ export function* tokens(string) {
|
|
|
56
59
|
switch (state) {
|
|
57
60
|
case "string-escaping-hex":
|
|
58
61
|
hex += c;
|
|
62
|
+
// @ts-ignore
|
|
59
63
|
if (hex.length === 4) {
|
|
64
|
+
// @ts-ignore
|
|
60
65
|
buffer += String.fromCharCode(parseInt(hex, 16));
|
|
61
66
|
state = "string";
|
|
62
67
|
}
|
|
@@ -263,7 +268,10 @@ export function* tokens(string) {
|
|
|
263
268
|
case undefined:
|
|
264
269
|
break;
|
|
265
270
|
case "string":
|
|
266
|
-
|
|
271
|
+
const error = new Error("unterminated string");
|
|
272
|
+
// @ts-ignore
|
|
273
|
+
error.expression = string;
|
|
274
|
+
throw error;
|
|
267
275
|
case "number":
|
|
268
276
|
case "identifier":
|
|
269
277
|
yield buffer;
|