@cabloy/utils 1.0.36 → 1.0.38
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/check.d.ts +2 -0
- package/dist/check.js +6 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +11 -0
- package/package.json +2 -2
package/dist/check.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare const isNumber: (val: any) => val is number;
|
|
|
12
12
|
export declare const isConstructor: (val: any) => boolean;
|
|
13
13
|
export declare const isEmpty: (array: any) => boolean;
|
|
14
14
|
export declare const isSymbol: (val: any) => val is symbol;
|
|
15
|
+
export declare function isClass(fn: any): boolean;
|
|
16
|
+
export declare function isClassStrict(fn: any): boolean;
|
|
15
17
|
export declare function isPromise(obj: any): obj is Promise<any>;
|
|
16
18
|
export declare function isNilOrEmptyString(str?: string | undefined | null): str is null | undefined | '';
|
|
17
19
|
export declare function checkMeta(meta?: {}, data?: {}): boolean;
|
package/dist/check.js
CHANGED
|
@@ -36,6 +36,12 @@ export const isNumber = (val) => typeof val === 'number';
|
|
|
36
36
|
export const isConstructor = (val) => val === 'constructor';
|
|
37
37
|
export const isEmpty = (array) => !(array && array.length > 0);
|
|
38
38
|
export const isSymbol = (val) => typeof val === 'symbol';
|
|
39
|
+
export function isClass(fn) {
|
|
40
|
+
return typeof fn === 'function' && !!fn.name && fn.prototype?.constructor === fn;
|
|
41
|
+
}
|
|
42
|
+
export function isClassStrict(fn) {
|
|
43
|
+
return typeof fn === 'function' && /^class(?:\s|\{)/.test(fn.toString());
|
|
44
|
+
}
|
|
39
45
|
export function isPromise(obj) {
|
|
40
46
|
return obj instanceof Promise || (obj && typeof obj.then === 'function');
|
|
41
47
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export declare function combineParamsAndQuery(path: string, options?: {
|
|
|
14
14
|
}): string;
|
|
15
15
|
export declare function combineQueries(pagePath?: string, queries?: Record<string, any>): string;
|
|
16
16
|
export declare function defaultPathSerializer(pathName: string, pathParams?: Record<string, any>): string;
|
|
17
|
+
export declare function ensureArray(arr: any, sep?: string): any[] | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -167,3 +167,14 @@ export function defaultPathSerializer(pathName, pathParams) {
|
|
|
167
167
|
}
|
|
168
168
|
return pathName;
|
|
169
169
|
}
|
|
170
|
+
export function ensureArray(arr, sep) {
|
|
171
|
+
if (arr === undefined || arr === null)
|
|
172
|
+
return undefined;
|
|
173
|
+
if (arr === '')
|
|
174
|
+
return [];
|
|
175
|
+
if (Array.isArray(arr))
|
|
176
|
+
return arr;
|
|
177
|
+
if (typeof arr === 'string' && sep !== null)
|
|
178
|
+
return arr.split(sep ?? ',');
|
|
179
|
+
return [arr];
|
|
180
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabloy/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.38",
|
|
5
5
|
"description": "cabloy utils",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@cabloy/cel-js": "^0.7.4",
|
|
29
|
-
"@cabloy/module-info": "^1.3.
|
|
29
|
+
"@cabloy/module-info": "^1.3.25",
|
|
30
30
|
"@cabloy/word-utils": "^2.0.1",
|
|
31
31
|
"chevrotain": "^11.0.3",
|
|
32
32
|
"object-hash": "^3.0.0"
|