pacc 4.39.0 → 4.39.2
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 +1 -1
- package/src/expression.mjs +12 -5
- package/types/expression.d.mts +2 -2
package/package.json
CHANGED
package/src/expression.mjs
CHANGED
|
@@ -248,12 +248,15 @@ export function parse(input, context = { globals }) {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
left.path.push(args);
|
|
251
|
-
left.eval = node => {
|
|
251
|
+
left.eval = (node, current) => {
|
|
252
252
|
const args = node.path[1].map(a =>
|
|
253
|
-
typeof a === "object" ? a.eval(a) : a
|
|
253
|
+
typeof a === "object" ? a.eval(a, current) : a
|
|
254
254
|
);
|
|
255
255
|
return context.globals[node.path[0]](...args);
|
|
256
256
|
};
|
|
257
|
+
|
|
258
|
+
advance();
|
|
259
|
+
|
|
257
260
|
return left;
|
|
258
261
|
}
|
|
259
262
|
break;
|
|
@@ -300,10 +303,14 @@ export function parse(input, context = { globals }) {
|
|
|
300
303
|
|
|
301
304
|
export const globals = {
|
|
302
305
|
in: (a, b) => {
|
|
303
|
-
if (
|
|
304
|
-
|
|
306
|
+
if (b?.[Symbol.iterator]) {
|
|
307
|
+
for (const x of b) {
|
|
308
|
+
if (x === a) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
305
312
|
}
|
|
306
|
-
return
|
|
313
|
+
return false;
|
|
307
314
|
},
|
|
308
315
|
min: (a, b) => (a < b ? a : b),
|
|
309
316
|
max: (a, b) => (a > b ? a : b),
|
package/types/expression.d.mts
CHANGED
|
@@ -1,7 +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) =>
|
|
4
|
+
in: (a: any, b: any) => boolean;
|
|
5
5
|
min: (a: any, b: any) => any;
|
|
6
6
|
max: (a: any, b: any) => any;
|
|
7
7
|
substring: (s: any, a: any, b: any) => any;
|
|
@@ -9,7 +9,7 @@ export function parse(input: any, context?: {
|
|
|
9
9
|
};
|
|
10
10
|
}): any;
|
|
11
11
|
export namespace globals {
|
|
12
|
-
export function _in(a: any, b: any):
|
|
12
|
+
export function _in(a: any, b: any): boolean;
|
|
13
13
|
export { _in as in };
|
|
14
14
|
export function min(a: any, b: any): any;
|
|
15
15
|
export function max(a: any, b: any): any;
|