@cabloy/utils 1.0.4 → 1.0.5

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/dist/cel.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type * as CelJS from 'cel-js' with { 'resolution-mode': 'import' };
2
+ export declare function evaluateExpressions(expressions: any, context?: Record<string, unknown>, functions?: Record<string, CallableFunction>): unknown;
2
3
  export declare function evaluate(expression: string, context?: Record<string, unknown>, functions?: Record<string, CallableFunction>): unknown;
3
4
  export declare function parse(expression: string): CelJS.ParseResult;
package/dist/cel.js CHANGED
@@ -1,4 +1,21 @@
1
1
  import * as celjs from 'cel-js';
2
+ import { isNil } from "./check.js";
3
+ export function evaluateExpressions(expressions, context, functions) {
4
+ if (isNil(expressions))
5
+ return expressions;
6
+ if (Array.isArray(expressions)) {
7
+ return expressions.map(item => evaluate(item, context, functions));
8
+ }
9
+ else if (typeof expressions === 'object') {
10
+ const res = {};
11
+ for (const key in expressions) {
12
+ res[key] = evaluate(expressions[key], context, functions);
13
+ }
14
+ return res;
15
+ }
16
+ // others
17
+ return evaluate(expressions, context, functions);
18
+ }
2
19
  export function evaluate(expression, context, functions) {
3
20
  if (typeof expression !== 'string')
4
21
  return expression;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cabloy/utils",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "description": "cabloy utils",
6
6
  "publishConfig": {
7
7
  "access": "public"