@lntvow/utils 2.3.3 → 2.3.4
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/index.cjs +1 -1
- package/dist/index.d.ts +48 -11
- package/dist/index.mjs +705 -267
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -60,7 +60,15 @@ export declare function deepClone<T>(target: T): T;
|
|
|
60
60
|
* @param options 配置对象
|
|
61
61
|
* @example deepMerge({ name: 1, obj: { name: '默认' , text: '旧值' }, arr: [1, 2, 3] }, { name: 1, obj: { name: '修改', age: '新增' }, test: 'test' }) => { name: 1, obj: { name: '修改', text: '旧值', age: '新增' }, arr: [1, 2, 3], test: 'test' }
|
|
62
62
|
*/
|
|
63
|
-
export declare function deepMerge(template: AnyObj, source: AnyObj, options?:
|
|
63
|
+
export declare function deepMerge(template: AnyObj, source: AnyObj, options?: DeepMergeOptions): any;
|
|
64
|
+
|
|
65
|
+
declare interface DeepMergeOptions {
|
|
66
|
+
/**
|
|
67
|
+
* @description 是否开启深拷贝 默认开启
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
clone: boolean;
|
|
71
|
+
}
|
|
64
72
|
|
|
65
73
|
export declare const error: (...arg: unknown[]) => void;
|
|
66
74
|
|
|
@@ -88,12 +96,42 @@ export declare interface FloatOptions {
|
|
|
88
96
|
integer?: boolean;
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
/**
|
|
100
|
+
* @description 生成随机数组
|
|
101
|
+
* @example generateRandomArray(4, () => 1) => [1, 1, 1, 1]
|
|
102
|
+
* */
|
|
103
|
+
export declare function generateRandomArray<T>(num: number, cb: () => T): T[];
|
|
104
|
+
|
|
91
105
|
/**
|
|
92
106
|
* @description 生成随机颜色
|
|
93
107
|
* @example generateRandomColor() => '#f36a38'
|
|
94
108
|
* */
|
|
95
109
|
export declare function generateRandomColor(): string;
|
|
96
110
|
|
|
111
|
+
export declare interface GenerateRandomDate {
|
|
112
|
+
/**
|
|
113
|
+
* @description 开始时间
|
|
114
|
+
* @default 1800-01-01 00:00:00
|
|
115
|
+
*/
|
|
116
|
+
start?: string | Date;
|
|
117
|
+
/**
|
|
118
|
+
* @description 结束时间
|
|
119
|
+
* @default 当前时间
|
|
120
|
+
*/
|
|
121
|
+
end?: string | Date;
|
|
122
|
+
/**
|
|
123
|
+
* @description 时间格式
|
|
124
|
+
* @default YYYY-MM-DD HH:mm:ss
|
|
125
|
+
*/
|
|
126
|
+
format?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @description 生成随机时间
|
|
131
|
+
* @example generateRandomDate() => '2021-07-01 08:51:34'
|
|
132
|
+
* */
|
|
133
|
+
export declare function generateRandomDate(options?: GenerateRandomDate): string;
|
|
134
|
+
|
|
97
135
|
/**
|
|
98
136
|
* @description 生成随机邮箱
|
|
99
137
|
* @example generateRandomEmail() => lZtJqMl0dyTO3WDGzFDO@example.com
|
|
@@ -110,9 +148,9 @@ export declare function generateRandomFloat(min?: number, max?: number): number;
|
|
|
110
148
|
|
|
111
149
|
/**
|
|
112
150
|
* @description 生成随机二代身份证号
|
|
113
|
-
* @example generateRandomIdCard() =>
|
|
151
|
+
* @example generateRandomIdCard() => '410304200210165258'
|
|
114
152
|
*/
|
|
115
|
-
export declare function generateRandomIdCard(): string
|
|
153
|
+
export declare function generateRandomIdCard(): string;
|
|
116
154
|
|
|
117
155
|
/**
|
|
118
156
|
* @description 生成范围内的随机整数
|
|
@@ -183,6 +221,13 @@ export declare function isChinese(val: string): boolean;
|
|
|
183
221
|
|
|
184
222
|
export declare const isDate: (val: unknown) => val is Date;
|
|
185
223
|
|
|
224
|
+
/**
|
|
225
|
+
* @description 校验是否为合法时间格式
|
|
226
|
+
* @param format 时间格式 默认 YYYY-MM-DD HH:mm:ss
|
|
227
|
+
* @link https://day.js.org/docs/zh-CN/parse/string-format
|
|
228
|
+
*/
|
|
229
|
+
export declare function isDateString(val: string, format?: string): boolean;
|
|
230
|
+
|
|
186
231
|
export declare const isDef: <T>(val: T) => val is NonNullable<T>;
|
|
187
232
|
|
|
188
233
|
/**
|
|
@@ -323,14 +368,6 @@ export declare const log: (name: unknown, ...arg: unknown[]) => void;
|
|
|
323
368
|
|
|
324
369
|
export declare const objectToString: () => string;
|
|
325
370
|
|
|
326
|
-
declare interface Options {
|
|
327
|
-
/**
|
|
328
|
-
* @description 是否开启深拷贝 默认开启
|
|
329
|
-
* @default true
|
|
330
|
-
*/
|
|
331
|
-
clone: boolean;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
371
|
/**
|
|
335
372
|
* @description 解析查询字符串
|
|
336
373
|
* @param str 转换的字符串
|