pacc 4.26.0 → 4.27.1
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 +8 -1
- package/types/expression.d.mts +14 -1
package/package.json
CHANGED
package/src/expression.mjs
CHANGED
|
@@ -53,7 +53,7 @@ export function binop(op, left, right, fallback) {
|
|
|
53
53
|
return fallback(op, left, right);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function parse(input, context = {}) {
|
|
56
|
+
export function parse(input, context = { globals }) {
|
|
57
57
|
input = tokens(input);
|
|
58
58
|
|
|
59
59
|
let node, token, value;
|
|
@@ -289,3 +289,10 @@ export function parse(input, context = {}) {
|
|
|
289
289
|
|
|
290
290
|
return result;
|
|
291
291
|
}
|
|
292
|
+
|
|
293
|
+
export const globals = {
|
|
294
|
+
min: (a, b) => (a < b ? a : b),
|
|
295
|
+
max: (a, b) => (a > b ? a : b),
|
|
296
|
+
substring: (s, a, b) => s.substring(a, b),
|
|
297
|
+
length: s => s.length
|
|
298
|
+
};
|
package/types/expression.d.mts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
export function binop(op: any, left: any, right: any, fallback: any): any;
|
|
2
|
-
export function parse(input: any, context?: {
|
|
2
|
+
export function parse(input: any, context?: {
|
|
3
|
+
globals: {
|
|
4
|
+
min: (a: any, b: any) => any;
|
|
5
|
+
max: (a: any, b: any) => any;
|
|
6
|
+
substring: (s: any, a: any, b: any) => any;
|
|
7
|
+
length: (s: any) => any;
|
|
8
|
+
};
|
|
9
|
+
}): any;
|
|
10
|
+
export namespace globals {
|
|
11
|
+
function min(a: any, b: any): any;
|
|
12
|
+
function max(a: any, b: any): any;
|
|
13
|
+
function substring(s: any, a: any, b: any): any;
|
|
14
|
+
function length(s: any): any;
|
|
15
|
+
}
|