@brix-sdk/platform-shared 1.0.0

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.
@@ -0,0 +1,795 @@
1
+ export { S as SimpleSnowflake, c as createDailySequenceIdGenerator, a as createSequenceIdGenerator, e as extractTimestampFromId, g as generateNanoId, b as generateShortId, d as generateSnowflakeId, f as generateTimestampId, h as generateUUID, i as isValidUUID } from '../id-BFKGN254.js';
2
+
3
+ /**
4
+ * Copyright 2026 Brix Platform Authors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * @file Debounce and throttle utilities
20
+ * @description Provides debounce and throttle functions
21
+ * @module @brix-sdk/platform-shared/utils/debounce
22
+ * @version 3.0.0
23
+ */
24
+ /**
25
+ * Debounce function
26
+ *
27
+ * Delays function execution until stopped calling for a period of time.
28
+ *
29
+ * @param fn - Function to debounce
30
+ * @param delay - Delay in milliseconds
31
+ * @returns Debounced function
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const debouncedSearch = debounce((query: string) => {
36
+ * search(query);
37
+ * }, 300);
38
+ *
39
+ * input.addEventListener('input', (e) => {
40
+ * debouncedSearch(e.target.value);
41
+ * });
42
+ * ```
43
+ */
44
+ declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (this: ThisParameterType<T>, ...args: Parameters<T>) => void;
45
+ /**
46
+ * Throttle function
47
+ *
48
+ * Limits function execution frequency to execute only once within specified time.
49
+ *
50
+ * @param fn - Function to throttle
51
+ * @param limit - Limit in milliseconds
52
+ * @returns Throttled function
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const throttledScroll = throttle(() => {
57
+ * updatePosition();
58
+ * }, 100);
59
+ *
60
+ * window.addEventListener('scroll', throttledScroll);
61
+ * ```
62
+ */
63
+ declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, limit: number): (this: ThisParameterType<T>, ...args: Parameters<T>) => void;
64
+
65
+ /**
66
+ * Copyright 2026 Brix Platform Authors
67
+ *
68
+ * Licensed under the Apache License, Version 2.0 (the "License");
69
+ * you may not use this file except in compliance with the License.
70
+ * You may obtain a copy of the License at
71
+ *
72
+ * http://www.apache.org/licenses/LICENSE-2.0
73
+ *
74
+ * Unless required by applicable law or agreed to in writing, software
75
+ * distributed under the License is distributed on an "AS IS" BASIS,
76
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77
+ * See the License for the specific language governing permissions and
78
+ * limitations under the License.
79
+ */
80
+ /**
81
+ * @file Type guard utilities
82
+ * @description Provides type guards and assertion functions
83
+ * @module @brix-sdk/platform-shared/utils/guards
84
+ * @version 3.0.0
85
+ */
86
+ /**
87
+ * Check if value is null or undefined
88
+ *
89
+ * @param value - Value to check
90
+ * @returns Whether value is null or undefined
91
+ */
92
+ declare function isNullOrUndefined(value: unknown): value is null | undefined;
93
+ /**
94
+ * Check if value is non-null and non-undefined
95
+ *
96
+ * @param value - Value to check
97
+ * @returns Whether value is non-null
98
+ */
99
+ declare function isNotNullOrUndefined<T>(value: T): value is NonNullable<T>;
100
+ /**
101
+ * Check if value is a string
102
+ *
103
+ * @param value - Value to check
104
+ * @returns Whether value is a string
105
+ */
106
+ declare function isString(value: unknown): value is string;
107
+ /**
108
+ * Check if value is a number
109
+ *
110
+ * @param value - Value to check
111
+ * @returns Whether value is a number
112
+ */
113
+ declare function isNumber(value: unknown): value is number;
114
+ /**
115
+ * Check if value is a boolean
116
+ *
117
+ * @param value - Value to check
118
+ * @returns Whether value is a boolean
119
+ */
120
+ declare function isBoolean(value: unknown): value is boolean;
121
+ /**
122
+ * Check if value is a function
123
+ *
124
+ * @param value - Value to check
125
+ * @returns Whether value is a function
126
+ */
127
+ declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
128
+ /**
129
+ * Check if value is an object
130
+ *
131
+ * @param value - Value to check
132
+ * @returns Whether value is an object
133
+ */
134
+ declare function isObject(value: unknown): value is Record<string, unknown>;
135
+ /**
136
+ * Check if value is an array
137
+ *
138
+ * @param value - Value to check
139
+ * @returns Whether value is an array
140
+ */
141
+ declare function isArray(value: unknown): value is unknown[];
142
+ /**
143
+ * Check if value is a Promise
144
+ *
145
+ * @param value - Value to check
146
+ * @returns Whether value is a Promise
147
+ */
148
+ declare function isPromise(value: unknown): value is Promise<unknown>;
149
+ /**
150
+ * Assert value is non-null
151
+ *
152
+ * @param value - Value to assert
153
+ * @param message - Error message
154
+ */
155
+ declare function assertNotNull<T>(value: T, message?: string): asserts value is NonNullable<T>;
156
+ /**
157
+ * Assert condition is true
158
+ *
159
+ * @param condition - Condition to assert
160
+ * @param message - Error message
161
+ */
162
+ declare function assert(condition: boolean, message?: string): asserts condition;
163
+
164
+ /**
165
+ * Copyright 2026 Brix Platform Authors
166
+ *
167
+ * Licensed under the Apache License, Version 2.0 (the "License");
168
+ * you may not use this file except in compliance with the License.
169
+ * You may obtain a copy of the License at
170
+ *
171
+ * http://www.apache.org/licenses/LICENSE-2.0
172
+ *
173
+ * Unless required by applicable law or agreed to in writing, software
174
+ * distributed under the License is distributed on an "AS IS" BASIS,
175
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
176
+ * See the License for the specific language governing permissions and
177
+ * limitations under the License.
178
+ */
179
+ /**
180
+ * @file Deep clone utility
181
+ * @description Provides deep clone functions
182
+ * @module @brix-sdk/platform-shared/utils/clone
183
+ * @version 3.0.0
184
+ */
185
+ /**
186
+ * Deep clone an object
187
+ *
188
+ * Supports Date, RegExp, Map, Set, and other types.
189
+ *
190
+ * @param obj - Object to clone
191
+ * @returns Cloned object
192
+ */
193
+ declare function deepClone<T>(obj: T): T;
194
+ /**
195
+ * Deep merge objects
196
+ *
197
+ * @param target - Target object
198
+ * @param sources - Source objects array
199
+ * @returns Merged object
200
+ */
201
+ declare function deepMerge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
202
+
203
+ /**
204
+ * @file format.ts
205
+ * @description 格式化工具函数集
206
+ * @module @brix-sdk/utils/format
207
+ * @version 3.0.0
208
+ *
209
+ * 【模块说明�? * 提供各种数据格式化工具,包括文件大小、日期时间、数字、货币、字符串等�? * 这些函数遵循中国大陆的常用格式习惯,同时支持国际化配置�? *
210
+ * 【使用场景�? * - 文件大小:上传下载、存储空间显�? * - 日期格式化:时间显示、相对时间、倒计�? * - 数字格式化:金额、百分比、统计数�? * - 字符串处理:截断、大小写转换
211
+ *
212
+ * @license Apache-2.0
213
+ */
214
+ /**
215
+ * 格式化文件大�? *
216
+ * 【功能说明�? * 将字节数转换为人类可读的文件大小格式�? * 自动选择合适的单位(B、KB、MB、GB 等)�? *
217
+ * @param bytes 字节�? * @param decimals 小数位数(默�?2�? * @returns 格式化后的字符串
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * formatFileSize(0); // '0 B'
222
+ * formatFileSize(1024); // '1 KB'
223
+ * formatFileSize(1048576); // '1 MB'
224
+ * formatFileSize(1073741824); // '1 GB'
225
+ * formatFileSize(1536, 1); // '1.5 KB'
226
+ * ```
227
+ */
228
+ declare function formatFileSize(bytes: number, decimals?: number): string;
229
+ /**
230
+ * 解析文件大小字符串为字节�? *
231
+ * 【功能说明�? * 将文件大小字符串(如 '1 MB', '500KB')解析为字节数�? * 支持各种常见格式,大小写不敏感�? *
232
+ * @param sizeStr 文件大小字符�? * @returns 字节数(解析失败返回 0�? *
233
+ * @example
234
+ * ```typescript
235
+ * parseFileSize('1 KB'); // 1024
236
+ * parseFileSize('1.5MB'); // 1572864
237
+ * parseFileSize('2 GB'); // 2147483648
238
+ * parseFileSize('invalid'); // 0
239
+ * ```
240
+ */
241
+ declare function parseFileSize(sizeStr: string): number;
242
+ /**
243
+ * 格式化日�? *
244
+ * 【功能说明�? * 将日期格式化为指定格式的字符串�? * 支持常用的占位符,如 YYYY、MM、DD、HH、mm、ss 等�? *
245
+ * 【支持的占位符�? * - YYYY: 四位年份
246
+ * - YY: 两位年份
247
+ * - MM: 两位月份�?1-12�? * - M: 月份�?-12�? * - DD: 两位日期�?1-31�? * - D: 日期�?-31�? * - HH: 两位小时�?0-23�? * - H: 小时�?-23�? * - mm: 两位分钟�?0-59�? * - m: 分钟�?-59�? * - ss: 两位秒(00-59�? * - s: 秒(0-59�? * - SSS: 毫秒
248
+ *
249
+ * @param date 日期(Date 对象、时间戳或日期字符串�? * @param format 格式字符串(默认 'YYYY-MM-DD HH:mm:ss'�? * @returns 格式化后的日期字符串
250
+ *
251
+ * @example
252
+ * ```typescript
253
+ * formatDate(new Date(), 'YYYY-MM-DD'); // '2024-01-01'
254
+ * formatDate(Date.now(), 'YYYY-MM-DD HH:mm:ss'); // '2024-01-01 12:00:00'
255
+ * formatDate(new Date(), 'YYYY年MM月DD�?); // '2024�?1�?1�?
256
+ * formatDate(new Date(), 'MM/DD/YYYY'); // '01/01/2024'
257
+ * ```
258
+ */
259
+ declare function formatDate(date: Date | number | string, format?: string): string;
260
+ /**
261
+ * 格式化相对时�? *
262
+ * 【功能说明�? * 将日期转换为相对于当前时间的描述,如"3分钟�?�?2天后"�? * 使用中文描述,适合中国用户的阅读习惯�? *
263
+ * @param date 日期(Date 对象、时间戳或日期字符串�? * @param now 当前时间戳(默认 Date.now()�? * @returns 相对时间字符�? *
264
+ * @example
265
+ * ```typescript
266
+ * formatRelativeTime(Date.now() - 30000); // '30秒前'
267
+ * formatRelativeTime(Date.now() - 3600000); // '1小时�?
268
+ * formatRelativeTime(Date.now() - 86400000); // '1天前'
269
+ * formatRelativeTime(Date.now() + 86400000); // '1天后'
270
+ * formatRelativeTime(Date.now() - 5000); // '刚刚'
271
+ * ```
272
+ */
273
+ declare function formatRelativeTime(date: Date | number | string, now?: number): string;
274
+ /**
275
+ * 格式化时�? *
276
+ * 【功能说明�? * 将毫秒数格式化为时长字符串�? * 支持短格式(1:01:01)和长格式(1小时1分钟1秒)两种风格�? *
277
+ * @param ms 毫秒�? * @param options 格式选项
278
+ * @param options.style 格式风格�?short'(默认)�?'long'
279
+ * @returns 格式化后的时长字符串
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * formatDuration(3661000); // '1:01:01'
284
+ * formatDuration(3661000, { style: 'long' }); // '1小时1分钟1�?
285
+ * formatDuration(65000); // '1:05'
286
+ * formatDuration(90061000); // '1d 1:01:01'
287
+ * ```
288
+ */
289
+ declare function formatDuration(ms: number, options?: {
290
+ style?: 'short' | 'long';
291
+ }): string;
292
+ /**
293
+ * 格式化数字为千分�? *
294
+ * 【功能说明�? * 将数字格式化为带千分位分隔符的字符串�? * 可指定小数位数�? *
295
+ * @param num 数字
296
+ * @param decimals 小数位数(可选)
297
+ * @returns 格式化后的字符串
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * formatNumber(1234567); // '1,234,567'
302
+ * formatNumber(1234567.89, 2); // '1,234,567.89'
303
+ * formatNumber(1000, 2); // '1,000.00'
304
+ * formatNumber(NaN); // 'NaN'
305
+ * formatNumber(Infinity); // '�?
306
+ * ```
307
+ */
308
+ declare function formatNumber(num: number, decimals?: number): string;
309
+ /**
310
+ * 格式化百分比
311
+ *
312
+ * 【功能说明�? * 将数值格式化为百分比字符串�? * 支持将比率(0-1)或百分比值转换为显示格式�? *
313
+ * @param value 数�? * @param decimals 小数位数(默�?2�? * @param asRatio 值是否为比率�?-1),默认 true
314
+ * @returns 格式化后的百分比字符�? *
315
+ * @example
316
+ * ```typescript
317
+ * formatPercent(0.1234); // '12.34%'
318
+ * formatPercent(0.1234, 1); // '12.3%'
319
+ * formatPercent(12.34, 2, false); // '12.34%'
320
+ * formatPercent(1); // '100.00%'
321
+ * ```
322
+ */
323
+ declare function formatPercent(value: number, decimals?: number, asRatio?: boolean): string;
324
+ /**
325
+ * 格式化货�? *
326
+ * 【功能说明�? * 将金额格式化为货币字符串�? * 使用 Intl.NumberFormat 实现,支持国际化�? *
327
+ * @param amount 金额
328
+ * @param currency 货币代码(默�?'CNY'�? * @param locale 地区(默�?'zh-CN'�? * @returns 格式化后的货币字符串
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * formatCurrency(1234.56); // '¥1,234.56'
333
+ * formatCurrency(1234.56, 'USD', 'en-US'); // '$1,234.56'
334
+ * formatCurrency(1234.56, 'EUR', 'de-DE'); // '1.234,56 �?
335
+ * formatCurrency(1234.56, 'JPY', 'ja-JP'); // '�?,235'
336
+ * ```
337
+ */
338
+ declare function formatCurrency(amount: number, currency?: string, locale?: string): string;
339
+ /**
340
+ * 截断字符�? *
341
+ * 【功能说明�? * 将超长字符串截断并添加后缀�? * 常用于显示标题、描述等需要限制长度的文本�? *
342
+ * @param str 原字符串
343
+ * @param maxLength 最大长�? * @param suffix 截断后缀(默�?'...'�? * @returns 截断后的字符�? *
344
+ * @example
345
+ * ```typescript
346
+ * truncate('这是一段很长的文字', 5); // '这是...'
347
+ * truncate('短文�?, 10); // '短文�?
348
+ * truncate('Hello World', 8, '�?); // 'Hello W�?
349
+ * ```
350
+ */
351
+ declare function truncate(str: string, maxLength: number, suffix?: string): string;
352
+ /**
353
+ * 首字母大�? *
354
+ * 【功能说明�? * 将字符串的首字母转为大写,其余保持不变�? *
355
+ * @param str 原字符串
356
+ * @returns 首字母大写的字符�? *
357
+ * @example
358
+ * ```typescript
359
+ * capitalize('hello'); // 'Hello'
360
+ * capitalize('WORLD'); // 'WORLD'
361
+ * capitalize(''); // ''
362
+ * ```
363
+ */
364
+ declare function capitalize(str: string): string;
365
+ /**
366
+ * 驼峰转短横线(kebab-case�? *
367
+ * 【功能说明�? * 将驼峰命名转换为短横线命名�? * 常用�?CSS 类名、URL 路径等场景�? *
368
+ * @param str 驼峰命名的字符串
369
+ * @returns 短横线命名的字符�? *
370
+ * @example
371
+ * ```typescript
372
+ * kebabCase('backgroundColor'); // 'background-color'
373
+ * kebabCase('myComponent'); // 'my-component'
374
+ * kebabCase('XMLHttpRequest'); // 'x-m-l-http-request'
375
+ * ```
376
+ */
377
+ declare function kebabCase(str: string): string;
378
+ /**
379
+ * 短横线转驼峰(camelCase�? *
380
+ * 【功能说明�? * 将短横线命名转换为驼峰命名�? * 常用于将 CSS 属性名转换�?JavaScript 属性名�? *
381
+ * @param str 短横线命名的字符�? * @returns 驼峰命名的字符串
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * camelCase('background-color'); // 'backgroundColor'
386
+ * camelCase('my-component'); // 'myComponent'
387
+ * camelCase('font-size'); // 'fontSize'
388
+ * ```
389
+ */
390
+ declare function camelCase(str: string): string;
391
+
392
+ /**
393
+ * 延迟执行
394
+ *
395
+ * 【功能说明�? * 返回一个在指定时间后解决的 Promise�? * 用于 async/await 语法中实现等待效果�? *
396
+ * @param ms 延迟时间(毫秒)
397
+ * @returns Promise<void>
398
+ *
399
+ * @example
400
+ * ```typescript
401
+ * // 基础用法
402
+ * await delay(1000);
403
+ * console.log('1秒后执行');
404
+ *
405
+ * // 动画间隔
406
+ * for (const item of items) {
407
+ * await fadeIn(item);
408
+ * await delay(200);
409
+ * }
410
+ * ```
411
+ */
412
+ declare function delay(ms: number): Promise<void>;
413
+ /**
414
+ * 带返回值的延迟
415
+ *
416
+ * 【功能说明�? * 延迟指定时间后返回指定的值�? * 适用于需要延迟返回特定值的场景�? *
417
+ * @template T 返回值类�? * @param ms 延迟时间(毫秒)
418
+ * @param value 返回�? * @returns Promise<T>
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * // 延迟返回默认�? * const result = await delayWith(1000, { status: 'ready' });
423
+ *
424
+ * // Promise.race 超时降级
425
+ * const data = await Promise.race([
426
+ * fetchData(),
427
+ * delayWith(5000, defaultData),
428
+ * ]);
429
+ * ```
430
+ */
431
+ declare function delayWith<T>(ms: number, value: T): Promise<T>;
432
+ /**
433
+ * 可取消延迟接�? */
434
+ interface CancelableDelay {
435
+ /** 延迟 Promise */
436
+ promise: Promise<void>;
437
+ /** 取消延迟 */
438
+ cancel: () => void;
439
+ }
440
+ /**
441
+ * 创建可取消的延迟
442
+ *
443
+ * 【功能说明�? * 创建一个可以被手动取消的延迟�? * 适用于需要中断等待的场景,如组件卸载时�? *
444
+ * @param ms 延迟时间(毫秒)
445
+ * @returns 可取消的延迟对象
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * const { promise, cancel } = cancelableDelay(5000);
450
+ *
451
+ * // 设置取消条件
452
+ * button.onclick = cancel;
453
+ *
454
+ * try {
455
+ * await promise;
456
+ * showMessage('操作完成');
457
+ * } catch (e) {
458
+ * showMessage('操作已取�?);
459
+ * }
460
+ * ```
461
+ */
462
+ declare function cancelableDelay(ms: number): CancelableDelay;
463
+ /**
464
+ * 带超时的 Promise 包装
465
+ *
466
+ * 【功能说明�? * 为任�?Promise 添加超时限制,超时后抛出错误�? * 适用于网络请求、长时间操作等需要超时控制的场景�? *
467
+ * @template T Promise 解析类型
468
+ * @param promise 原始 Promise
469
+ * @param ms 超时时间(毫秒)
470
+ * @param message 超时错误消息(可选)
471
+ * @returns Promise<T>
472
+ * @throws Error 超时时抛出错�? *
473
+ * @example
474
+ * ```typescript
475
+ * // API 请求超时
476
+ * try {
477
+ * const data = await withTimeout(
478
+ * fetch('/api/data'),
479
+ * 5000,
480
+ * '请求超时,请检查网�?
481
+ * );
482
+ * } catch (e) {
483
+ * if (e.message.includes('超时')) {
484
+ * showRetryDialog();
485
+ * }
486
+ * }
487
+ *
488
+ * // 文件上传超时
489
+ * await withTimeout(uploadFile(file), 60000, '上传超时');
490
+ * ```
491
+ */
492
+ declare function withTimeout<T>(promise: Promise<T>, ms: number, message?: string): Promise<T>;
493
+ /**
494
+ * 在下一个宏任务中执�? *
495
+ * 【功能说明�? * 将函数调度到下一个事件循环执行�? * 类似�?Vue �?nextTick,但更简单�? *
496
+ * @param fn 要执行的函数
497
+ *
498
+ * @example
499
+ * ```typescript
500
+ * // 确保 DOM 更新后执�? * element.innerHTML = newContent;
501
+ * nextTick(() => {
502
+ * element.querySelector('.new-element').focus();
503
+ * });
504
+ * ```
505
+ */
506
+ declare function nextTick(fn: () => void): void;
507
+ /**
508
+ * 请求空闲回调(带降级�? *
509
+ * 【功能说明�? * 在浏览器空闲时执行任务,支持不兼容浏览器的降级处理�? * 适用于低优先级的后台任务�? *
510
+ * @param fn 要执行的函数
511
+ * @param options 配置选项
512
+ * @param options.timeout 超时时间(毫秒)
513
+ * @returns 请求 ID
514
+ *
515
+ * @example
516
+ * ```typescript
517
+ * // 空闲时发送分析数�? * requestIdleCallback(() => {
518
+ * sendAnalytics(analyticsData);
519
+ * }, { timeout: 5000 });
520
+ *
521
+ * // 空闲时预加载资源
522
+ * requestIdleCallback(() => {
523
+ * preloadNextPageResources();
524
+ * });
525
+ * ```
526
+ */
527
+ declare function requestIdleCallback(fn: () => void, options?: {
528
+ timeout?: number;
529
+ }): number;
530
+
531
+ /**
532
+ * @file validators.ts
533
+ * @description 验证工具函数�? * @module @brix-sdk/utils/validators
534
+ * @version 3.0.0
535
+ *
536
+ * 【模块说明�? * 提供各种数据验证工具函数,包括基础格式验证、中国特有证件验证、密码强度检查等�? * 验证函数均返回布尔值,不抛出异常,便于条件判断使用�? *
537
+ * 【使用场景�? * - 表单验证:邮箱、手机号、密码等
538
+ * - 证件验证:身份证、统一社会信用代码、银行卡�? * - 数据校验:URL、IP、JSON 格式�? * - 类型检查:空值、数字、范围等
539
+ *
540
+ * @license Apache-2.0
541
+ */
542
+ /**
543
+ * 验证邮箱格式
544
+ *
545
+ * 【功能说明�? * 验证字符串是否为有效的邮箱地址格式�? * 使用 RFC 5322 简化版正则表达式�? *
546
+ * @param email 邮箱地址
547
+ * @returns 是否为有效邮箱格�? *
548
+ * @example
549
+ * ```typescript
550
+ * isValidEmail('user@example.com'); // true
551
+ * isValidEmail('user.name@domain.cn'); // true
552
+ * isValidEmail('invalid-email'); // false
553
+ * isValidEmail('user@'); // false
554
+ * isValidEmail(''); // false
555
+ * ```
556
+ */
557
+ declare function isValidEmail(email: string): boolean;
558
+ /**
559
+ * 验证中国大陆手机�? *
560
+ * 【功能说明�? * 验证字符串是否为有效的中国大陆手机号码�? * 支持目前所有运营商号段�?3x�?4x�?5x�?6x�?7x�?8x�?9x)�? *
561
+ * 【验证规则�? * - 11位数�? * - �?开�? * - 第二位为3-9
562
+ *
563
+ * @param phone 手机�? * @returns 是否为有效手机号
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * isValidPhone('13800138000'); // true
568
+ * isValidPhone('19912345678'); // true
569
+ * isValidPhone('12345678901'); // false(第二位不符合)
570
+ * isValidPhone('1380013800'); // false(位数不足)
571
+ * isValidPhone('138 0013 8000'); // false(含空格�? * ```
572
+ */
573
+ declare function isValidPhone(phone: string): boolean;
574
+ /**
575
+ * 验证 URL 格式
576
+ *
577
+ * 【功能说明�? * 验证字符串是否为有效�?HTTP/HTTPS URL�? * 使用原生 URL API 进行解析验证�? *
578
+ * @param url URL 字符�? * @returns 是否为有�?URL
579
+ *
580
+ * @example
581
+ * ```typescript
582
+ * isValidUrl('https://example.com'); // true
583
+ * isValidUrl('http://example.com/path'); // true
584
+ * isValidUrl('ftp://example.com'); // false(不支持 FTP�? * isValidUrl('not-a-url'); // false
585
+ * isValidUrl(''); // false
586
+ * ```
587
+ */
588
+ declare function isValidUrl(url: string): boolean;
589
+ /**
590
+ * 验证 IPv4 地址
591
+ *
592
+ * 【功能说明�? * 验证字符串是否为有效�?IPv4 地址格式�? *
593
+ * 【验证规则�? * - 四段数字,用点分�? * - 每段范围 0-255
594
+ * - 不允许前导零(如 01.02.03.04�? *
595
+ * @param ip IP 地址字符�? * @returns 是否为有�?IPv4 地址
596
+ *
597
+ * @example
598
+ * ```typescript
599
+ * isValidIPv4('192.168.1.1'); // true
600
+ * isValidIPv4('0.0.0.0'); // true
601
+ * isValidIPv4('255.255.255.255'); // true
602
+ * isValidIPv4('256.1.1.1'); // false(超出范围)
603
+ * isValidIPv4('01.02.03.04'); // false(前导零�? * isValidIPv4('192.168.1'); // false(不完整�? * ```
604
+ */
605
+ declare function isValidIPv4(ip: string): boolean;
606
+ /**
607
+ * 验证 JSON 字符�? *
608
+ * 【功能说明�? * 验证字符串是否为有效�?JSON 格式�? *
609
+ * @param str 待验证字符串
610
+ * @returns 是否为有�?JSON
611
+ *
612
+ * @example
613
+ * ```typescript
614
+ * isValidJSON('{"name":"test"}'); // true
615
+ * isValidJSON('[1, 2, 3]'); // true
616
+ * isValidJSON('true'); // true
617
+ * isValidJSON('{invalid}'); // false
618
+ * isValidJSON(''); // false
619
+ * ```
620
+ */
621
+ declare function isValidJSON(str: string): boolean;
622
+ /**
623
+ * 验证中国大陆身份证号
624
+ *
625
+ * 【功能说明�? * 验证字符串是否为有效的中国大陆居民身份证号�? * 支持18位(新版)和15位(老版)两种格式�? * 18位身份证会进行校验码验证�? *
626
+ * �?8位身份证结构�? * - �?位:地区�? * - 7-14位:出生日期(YYYYMMDD�? * - 15-17位:顺序码(�?7位奇数为男,偶数为女�? * - �?8位:校验码(0-9 �?X�? *
627
+ * @param idCard 身份证号
628
+ * @returns 是否为有效身份证�? *
629
+ * @example
630
+ * ```typescript
631
+ * isValidIdCard('110101199001011234'); // 需验证校验�? * isValidIdCard('110101900101123'); // 15位老版身份�? * isValidIdCard('12345678901234567'); // false(校验码错误�? * isValidIdCard(''); // false
632
+ * ```
633
+ */
634
+ declare function isValidIdCard(idCard: string): boolean;
635
+ /**
636
+ * 验证中国大陆统一社会信用代码
637
+ *
638
+ * 【功能说明�? * 验证字符串是否为有效的统一社会信用代码(企业信用代码)�? *
639
+ * 【代码结构�? * - �?位:登记管理部门代码�?位)
640
+ * - �?位:机构类别代码�?位)
641
+ * - �?-8位:登记管理机关行政区划码(6位数字)
642
+ * - �?-17位:主体标识码(组织机构代码�? * - �?8位:校验�? *
643
+ * @param code 统一社会信用代码
644
+ * @returns 是否为有效代�? *
645
+ * @example
646
+ * ```typescript
647
+ * isValidUnifiedCreditCode('91110000MA0ABCDE12'); // 需验证格式
648
+ * isValidUnifiedCreditCode(''); // false
649
+ * ```
650
+ */
651
+ declare function isValidUnifiedCreditCode(code: string): boolean;
652
+ /**
653
+ * 验证中国大陆银行卡号(Luhn算法�? *
654
+ * 【功能说明�? * 验证字符串是否为有效的银行卡号�? * 使用 Luhn 算法进行校验�? *
655
+ * 【Luhn 算法�? * 1. 从右向左,偶数位�?,若结果大于9则减9
656
+ * 2. 所有位数求�? * 3. 能被10整除则有�? *
657
+ * @param cardNumber 银行卡号
658
+ * @returns 是否为有效银行卡�? *
659
+ * @example
660
+ * ```typescript
661
+ * isValidBankCard('6222020200010001234'); // 需验证Luhn算法
662
+ * isValidBankCard('1234 5678 9012 3456'); // 支持带空�? * isValidBankCard('123'); // false(位数不足)
663
+ * ```
664
+ */
665
+ declare function isValidBankCard(cardNumber: string): boolean;
666
+ /**
667
+ * 密码强度等级
668
+ */
669
+ type PasswordStrength = 'weak' | 'medium' | 'strong' | 'very-strong';
670
+ /**
671
+ * 密码强度检查结�? */
672
+ interface PasswordStrengthResult {
673
+ /** 强度等级 */
674
+ strength: PasswordStrength;
675
+ /** 强度分数�?-10�?*/
676
+ score: number;
677
+ /** 改进建议列表 */
678
+ suggestions: string[];
679
+ }
680
+ /**
681
+ * 检查密码强�? *
682
+ * 【功能说明�? * 综合评估密码强度,返回强度等级、分数和改进建议�? *
683
+ * 【评分规则�? * - 长度�?位及以上 +1�?2位及以上 +1�?6位及以上 +1
684
+ * - 小写字母�?1
685
+ * - 大写字母�?1
686
+ * - 数字�?1
687
+ * - 特殊字符�?2
688
+ * - 常见模式�?2
689
+ *
690
+ * 【强度等级�? * - weak:分�?<= 2
691
+ * - medium:分�?3-4
692
+ * - strong:分�?5-6
693
+ * - very-strong:分�?>= 7
694
+ *
695
+ * @param password 密码
696
+ * @returns 强度检查结�? *
697
+ * @example
698
+ * ```typescript
699
+ * checkPasswordStrength('123456');
700
+ * // { strength: 'weak', score: 0, suggestions: ['密码长度至少8�?, ...] }
701
+ *
702
+ * checkPasswordStrength('MyP@ssw0rd');
703
+ * // { strength: 'strong', score: 7, suggestions: [] }
704
+ *
705
+ * checkPasswordStrength('VeryStr0ng!P@ssw0rd');
706
+ * // { strength: 'very-strong', score: 9, suggestions: [] }
707
+ * ```
708
+ */
709
+ declare function checkPasswordStrength(password: string): PasswordStrengthResult;
710
+ /**
711
+ * 检查是否为空�? *
712
+ * 【功能说明�? * 检查值是否为"�?。支持多种类型:
713
+ * - null/undefined:空
714
+ * - 字符串:空字符串或纯空白为空
715
+ * - 数组:空数组为空
716
+ * - 对象:空对象为空
717
+ *
718
+ * @param value 待检查的�? * @returns 是否为空
719
+ *
720
+ * @example
721
+ * ```typescript
722
+ * isEmpty(null); // true
723
+ * isEmpty(undefined); // true
724
+ * isEmpty(''); // true
725
+ * isEmpty(' '); // true
726
+ * isEmpty([]); // true
727
+ * isEmpty({}); // true
728
+ * isEmpty(0); // false
729
+ * isEmpty(false); // false
730
+ * isEmpty('hello'); // false
731
+ * ```
732
+ */
733
+ declare function isEmpty(value: unknown): boolean;
734
+ /**
735
+ * 检查是否为数字
736
+ *
737
+ * 【功能说明�? * 检查值是否为有效数字(包括数字类型和可解析的数字字符串)�? * 排除 NaN �?Infinity�? *
738
+ * @param value 待检查的�? * @returns 是否为有效数�? *
739
+ * @example
740
+ * ```typescript
741
+ * isNumeric(123); // true
742
+ * isNumeric('123'); // true
743
+ * isNumeric('12.34'); // true
744
+ * isNumeric('-100'); // true
745
+ * isNumeric(NaN); // false
746
+ * isNumeric(Infinity); // false
747
+ * isNumeric('abc'); // false
748
+ * isNumeric(''); // false
749
+ * ```
750
+ */
751
+ declare function isNumeric(value: unknown): boolean;
752
+ /**
753
+ * 检查是否为整数
754
+ *
755
+ * @param value 待检查的�? * @returns 是否为整�? *
756
+ * @example
757
+ * ```typescript
758
+ * isInteger(123); // true
759
+ * isInteger(-100); // true
760
+ * isInteger(12.34); // false
761
+ * isInteger('123'); // false(需为数字类型)
762
+ * ```
763
+ */
764
+ declare function isInteger(value: unknown): boolean;
765
+ /**
766
+ * 检查是否为正数
767
+ *
768
+ * @param value 待检查的数字
769
+ * @returns 是否为正�? *
770
+ * @example
771
+ * ```typescript
772
+ * isPositive(1); // true
773
+ * isPositive(0.001); // true
774
+ * isPositive(0); // false
775
+ * isPositive(-1); // false
776
+ * ```
777
+ */
778
+ declare function isPositive(value: number): boolean;
779
+ /**
780
+ * 检查是否在范围�? *
781
+ * @param value 待检查的数字
782
+ * @param min 最小值(包含�? * @param max 最大值(包含�? * @returns 是否在范围内
783
+ *
784
+ * @example
785
+ * ```typescript
786
+ * isInRange(5, 1, 10); // true
787
+ * isInRange(1, 1, 10); // true(包含边界)
788
+ * isInRange(10, 1, 10); // true(包含边界)
789
+ * isInRange(0, 1, 10); // false
790
+ * isInRange(11, 1, 10); // false
791
+ * ```
792
+ */
793
+ declare function isInRange(value: number, min: number, max: number): boolean;
794
+
795
+ export { type PasswordStrength, type PasswordStrengthResult, assert, assertNotNull, camelCase, cancelableDelay, capitalize, checkPasswordStrength, debounce, deepClone, deepMerge, delay, delayWith, formatCurrency, formatDate, formatDuration, formatFileSize, formatNumber, formatPercent, formatRelativeTime, isArray, isBoolean, isEmpty, isFunction, isInRange, isInteger, isNotNullOrUndefined, isNullOrUndefined, isNumber, isNumeric, isObject, isPositive, isPromise, isString, isValidBankCard, isValidEmail, isValidIPv4, isValidIdCard, isValidJSON, isValidPhone, isValidUnifiedCreditCode, isValidUrl, kebabCase, nextTick, parseFileSize, requestIdleCallback, throttle, truncate, withTimeout };