@cabloy/utils 1.0.14 → 1.0.17

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
File without changes
package/README.md CHANGED
File without changes
package/dist/cel.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type * as CelJS from 'cel-js' with { 'resolution-mode': 'import' };
2
+ import type { CstNode } from 'chevrotain';
2
3
  export declare function evaluateExpressions(expressions: any, context?: Record<string, unknown>, functions?: Record<string, CallableFunction>): unknown;
3
- export declare function evaluate(expression: string, context?: Record<string, unknown>, functions?: Record<string, CallableFunction>): unknown;
4
+ export declare function evaluate(expression: CstNode | string, context?: Record<string, unknown>, functions?: Record<string, CallableFunction>): unknown;
4
5
  export declare function parse(expression: string): CelJS.ParseResult;
package/dist/cel.js CHANGED
@@ -17,12 +17,19 @@ export function evaluateExpressions(expressions, context, functions) {
17
17
  return evaluate(expressions, context, functions);
18
18
  }
19
19
  export function evaluate(expression, context, functions) {
20
- if (typeof expression !== 'string')
21
- return expression;
22
- if (expression.startsWith('##')) {
23
- return expression.substring('##'.length);
20
+ // CstNode
21
+ if (typeof expression === 'object' && expression.children) {
22
+ return celjs.evaluate(expression, context, functions);
24
23
  }
25
- return celjs.evaluate(expression, context, functions);
24
+ // string
25
+ if (typeof expression === 'string') {
26
+ if (expression.startsWith('##')) {
27
+ return expression.substring('##'.length);
28
+ }
29
+ return celjs.evaluate(expression, context, functions);
30
+ }
31
+ // others
32
+ return expression;
26
33
  }
27
34
  export function parse(expression) {
28
35
  return celjs.parse(expression);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cabloy/utils",
3
3
  "type": "module",
4
- "version": "1.0.14",
4
+ "version": "1.0.17",
5
5
  "description": "cabloy utils",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -24,9 +24,19 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
+ "scripts": {
28
+ "lint": "eslint .",
29
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
30
+ "tsc:publish": "npm run clean && tsc",
31
+ "prepublishOnly": "npm run tsc:publish",
32
+ "prepack": "clean-package",
33
+ "postpack": "clean-package restore"
34
+ },
27
35
  "dependencies": {
28
- "@cabloy/word-utils": "^2.0.0",
36
+ "@cabloy/module-info": "^1.3.10",
37
+ "@cabloy/word-utils": "^2.0.1",
29
38
  "cel-js": "^0.3.1",
30
- "@cabloy/module-info": "^1.3.6"
31
- }
32
- }
39
+ "chevrotain": "^11.0.3"
40
+ },
41
+ "gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b"
42
+ }