@cabloy/utils 1.0.11 → 1.0.12

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/utils.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare function setProperty<T>(obj: object, name: string, value: T): voi
6
6
  export declare function getProperty<T>(obj: object, name: string, sep?: string): T | undefined;
7
7
  export declare function getPropertyObject<T>(obj: object, name: string, sep?: string): T | undefined;
8
8
  export declare function createFunction(expression: string, scopeKeys?: string[]): Function;
9
- export declare function evaluateSimple(expression: string): any;
9
+ export declare function evaluateSimple(expression: string, scope?: object): any;
10
10
  export declare function getRandomInt(size: number, start?: number): number;
11
11
  export declare function combineParamsAndQuery(path: string, options?: {
12
12
  params?: object;
package/dist/utils.js CHANGED
@@ -83,9 +83,11 @@ export function createFunction(expression, scopeKeys) {
83
83
  }
84
84
  return fn;
85
85
  }
86
- export function evaluateSimple(expression) {
87
- const fn = createFunction(expression);
88
- return fn();
86
+ export function evaluateSimple(expression, scope) {
87
+ const scopeKeys = scope ? Object.keys(scope) : undefined;
88
+ const scopeValues = scope ? Object.values(scope) : undefined;
89
+ const fn = createFunction(expression, scopeKeys);
90
+ return scopeValues ? fn(...scopeValues) : fn();
89
91
  }
90
92
  export function getRandomInt(size, start = 0) {
91
93
  return Math.floor(Math.random() * size) + start;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cabloy/utils",
3
3
  "type": "module",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
5
5
  "description": "cabloy utils",
6
6
  "publishConfig": {
7
7
  "access": "public"