@cabloy/utils 1.0.13 → 1.0.14
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 +2 -2
- package/dist/utils.js +3 -2
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare function catchError<T>(fnMethod: (...args: any[]) => Promise<T>):
|
|
|
3
3
|
export declare function sleep(ms: any): Promise<unknown>;
|
|
4
4
|
export declare function replaceTemplate(content: string, scope: object): string;
|
|
5
5
|
export declare function setProperty<T>(obj: object, name: string, value: T): void;
|
|
6
|
-
export declare function getProperty<T>(obj: object, name: string, sep?: string): T | undefined;
|
|
7
|
-
export declare function getPropertyObject<T>(obj: object, name: string, sep?: string): T | undefined;
|
|
6
|
+
export declare function getProperty<T>(obj: object | undefined, name: string, sep?: string): T | undefined;
|
|
7
|
+
export declare function getPropertyObject<T>(obj: object | undefined, name: string, sep?: string): T | undefined;
|
|
8
8
|
export declare function createFunction(expression: string, scopeKeys?: string[]): Function;
|
|
9
9
|
export declare function evaluateSimple(expression: string, scope?: object): any;
|
|
10
10
|
export declare function getRandomInt(size: number, start?: number): number;
|
package/dist/utils.js
CHANGED
|
@@ -53,9 +53,10 @@ export function getProperty(obj, name, sep) {
|
|
|
53
53
|
export function getPropertyObject(obj, name, sep) {
|
|
54
54
|
return _getProperty(obj, name, sep, true);
|
|
55
55
|
}
|
|
56
|
-
function _getProperty(
|
|
57
|
-
if (!
|
|
56
|
+
function _getProperty(_obj, name, sep, forceObject) {
|
|
57
|
+
if (!_obj)
|
|
58
58
|
return undefined;
|
|
59
|
+
let obj = _obj;
|
|
59
60
|
const names = name.split(sep || '.');
|
|
60
61
|
// loop
|
|
61
62
|
for (const name of names) {
|