pacc 4.37.7 → 4.39.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
package/src/expression.mjs
CHANGED
|
@@ -80,10 +80,14 @@ export function parse(input, context = { globals }) {
|
|
|
80
80
|
}
|
|
81
81
|
result = r;
|
|
82
82
|
} else {
|
|
83
|
-
if (result
|
|
84
|
-
result =
|
|
83
|
+
if (result === undefined && context.globals?.[p]) {
|
|
84
|
+
result = context.globals?.[p];
|
|
85
85
|
} else {
|
|
86
|
-
result
|
|
86
|
+
if (result instanceof Map) {
|
|
87
|
+
result = result.get(p);
|
|
88
|
+
} else {
|
|
89
|
+
result = result[p] ?? context.globals?.[p];
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
break;
|
|
@@ -117,7 +121,7 @@ export function parse(input, context = { globals }) {
|
|
|
117
121
|
|
|
118
122
|
const expect = expected => {
|
|
119
123
|
if (token !== expected) {
|
|
120
|
-
error(`unexpected '${token
|
|
124
|
+
error(`unexpected '${token?.str || token}' expecting '${expected.str}'`);
|
|
121
125
|
}
|
|
122
126
|
advance();
|
|
123
127
|
};
|
|
@@ -244,8 +248,12 @@ export function parse(input, context = { globals }) {
|
|
|
244
248
|
}
|
|
245
249
|
}
|
|
246
250
|
left.path.push(args);
|
|
247
|
-
left.eval = node =>
|
|
248
|
-
|
|
251
|
+
left.eval = node => {
|
|
252
|
+
const args = node.path[1].map(a =>
|
|
253
|
+
typeof a === "object" ? a.eval(a) : a
|
|
254
|
+
);
|
|
255
|
+
return context.globals[node.path[0]](...args);
|
|
256
|
+
};
|
|
249
257
|
return left;
|
|
250
258
|
}
|
|
251
259
|
break;
|
|
@@ -291,6 +299,12 @@ export function parse(input, context = { globals }) {
|
|
|
291
299
|
}
|
|
292
300
|
|
|
293
301
|
export const globals = {
|
|
302
|
+
in: (a, b) => {
|
|
303
|
+
if (Array.isArray(b)) {
|
|
304
|
+
return b.find(x => x === a) ? true : false;
|
|
305
|
+
}
|
|
306
|
+
return b.has(a);
|
|
307
|
+
},
|
|
294
308
|
min: (a, b) => (a < b ? a : b),
|
|
295
309
|
max: (a, b) => (a > b ? a : b),
|
|
296
310
|
substring: (s, a, b) => s.substring(a, b),
|
|
@@ -220,4 +220,4 @@ export type AttributeDefinition = {
|
|
|
220
220
|
*/
|
|
221
221
|
additionalValues?: object;
|
|
222
222
|
};
|
|
223
|
-
export { default_attribute as string_attribute, default_attribute_writable as string_attribute_writable, default_attribute as type_attribute, default_attribute_writable as state_attribute_writable, boolean_attribute_writable_true as active_attribute, secret_attribute as username_attribute, secret_attribute as password_attribute, secret_attribute as token_attribute, secret_attribute as certificate_attribute, integer_attribute as count_attribute, integer_attribute as size_attribute, default_attribute_writable as body_attribute_writable, number_attribute as duration_attribute };
|
|
223
|
+
export { default_attribute as string_attribute, default_attribute_writable as string_attribute_writable, description_attribute as description_attribute_writable, default_attribute as type_attribute, default_attribute_writable as state_attribute_writable, boolean_attribute_writable_true as active_attribute, secret_attribute as username_attribute, secret_attribute as password_attribute, secret_attribute as token_attribute, secret_attribute as certificate_attribute, integer_attribute as count_attribute, integer_attribute as size_attribute, default_attribute_writable as body_attribute_writable, number_attribute as duration_attribute };
|
package/types/expression.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export function binop(op: any, left: any, right: any, fallback: any): any;
|
|
2
2
|
export function parse(input: any, context?: {
|
|
3
3
|
globals: {
|
|
4
|
+
in: (a: any, b: any) => any;
|
|
4
5
|
min: (a: any, b: any) => any;
|
|
5
6
|
max: (a: any, b: any) => any;
|
|
6
7
|
substring: (s: any, a: any, b: any) => any;
|
|
@@ -8,8 +9,10 @@ export function parse(input: any, context?: {
|
|
|
8
9
|
};
|
|
9
10
|
}): any;
|
|
10
11
|
export namespace globals {
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
function
|
|
12
|
+
export function _in(a: any, b: any): any;
|
|
13
|
+
export { _in as in };
|
|
14
|
+
export function min(a: any, b: any): any;
|
|
15
|
+
export function max(a: any, b: any): any;
|
|
16
|
+
export function substring(s: any, a: any, b: any): any;
|
|
17
|
+
export function length(s: any): any;
|
|
15
18
|
}
|