@szkj/utils 0.0.1
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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/index.cjs +1850 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +401 -0
- package/dist/index.d.ts +401 -0
- package/dist/index.js +1698 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
interface MaskOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Number of characters to keep from the start.
|
|
4
|
+
*/
|
|
5
|
+
start?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Number of characters to keep from the end.
|
|
8
|
+
*/
|
|
9
|
+
end?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Character used to replace hidden content.
|
|
12
|
+
*/
|
|
13
|
+
maskChar?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Fixed mask length. When omitted, the hidden content length is used.
|
|
16
|
+
*/
|
|
17
|
+
maskLength?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface UniversalMaskOptions extends MaskOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Zero-based range to mask. The end index is not included.
|
|
23
|
+
*/
|
|
24
|
+
range?: [number, number];
|
|
25
|
+
/**
|
|
26
|
+
* Regular expression used to find content that should be masked.
|
|
27
|
+
*/
|
|
28
|
+
pattern?: RegExp;
|
|
29
|
+
/**
|
|
30
|
+
* Replacement used with pattern. When omitted, every matched
|
|
31
|
+
* character is replaced with maskChar.
|
|
32
|
+
*/
|
|
33
|
+
replacement?: string | ((match: string) => string);
|
|
34
|
+
}
|
|
35
|
+
declare function mask(value: string, options?: UniversalMaskOptions): string;
|
|
36
|
+
|
|
37
|
+
type MaskNameOptions = MaskOptions;
|
|
38
|
+
declare function maskName(name: string, options?: MaskNameOptions): string;
|
|
39
|
+
|
|
40
|
+
type MaskPhoneOptions = MaskOptions;
|
|
41
|
+
declare function maskPhone(phone: string, options?: MaskPhoneOptions): string;
|
|
42
|
+
|
|
43
|
+
type MaskFixedPhoneOptions = MaskOptions;
|
|
44
|
+
declare function maskFixedPhone(phone: string, options?: MaskFixedPhoneOptions): string;
|
|
45
|
+
|
|
46
|
+
type MaskEmailOptions = Omit<MaskOptions, 'end'>;
|
|
47
|
+
declare function maskEmail(email: string, options?: MaskEmailOptions): string;
|
|
48
|
+
|
|
49
|
+
type MaskIdCardOptions = MaskOptions;
|
|
50
|
+
declare function maskIdCard(idCard: string, options?: MaskIdCardOptions): string;
|
|
51
|
+
|
|
52
|
+
type MaskBankCardOptions = MaskOptions;
|
|
53
|
+
declare function maskBankCard(cardNo: string, options?: MaskBankCardOptions): string;
|
|
54
|
+
|
|
55
|
+
interface MaskAddressOptions extends Pick<MaskOptions, 'maskChar' | 'maskLength'> {
|
|
56
|
+
keepLength?: number;
|
|
57
|
+
}
|
|
58
|
+
declare function maskAddress(address: string, options?: MaskAddressOptions): string;
|
|
59
|
+
|
|
60
|
+
type MaskPassportOptions = MaskOptions;
|
|
61
|
+
declare function maskPassport(passport: string, options?: MaskPassportOptions): string;
|
|
62
|
+
|
|
63
|
+
type MaskCarPlateOptions = MaskOptions;
|
|
64
|
+
declare function maskCarPlate(plate: string, options?: MaskCarPlateOptions): string;
|
|
65
|
+
|
|
66
|
+
interface MaskIpOptions extends Pick<MaskOptions, 'maskChar'> {
|
|
67
|
+
segment?: number;
|
|
68
|
+
}
|
|
69
|
+
declare function maskIp(ip: string, options?: MaskIpOptions): string;
|
|
70
|
+
|
|
71
|
+
type MaskAccountOptions = MaskOptions;
|
|
72
|
+
declare function maskAccount(account: string, options?: MaskAccountOptions): string;
|
|
73
|
+
|
|
74
|
+
type MaskSecretOptions = MaskOptions;
|
|
75
|
+
declare function maskSecret(secret: string, options?: MaskSecretOptions): string;
|
|
76
|
+
|
|
77
|
+
declare const REGEXP_PHONE: RegExp;
|
|
78
|
+
declare const REGEXP_FIXED_PHONE: RegExp;
|
|
79
|
+
declare const REGEXP_EMAIL: RegExp;
|
|
80
|
+
declare const REGEXP_ID_CARD: RegExp;
|
|
81
|
+
declare const REGEXP_BANK_CARD: RegExp;
|
|
82
|
+
declare const REGEXP_PASSPORT: RegExp;
|
|
83
|
+
declare const REGEXP_CAR_PLATE: RegExp;
|
|
84
|
+
declare const REGEXP_URL: RegExp;
|
|
85
|
+
declare const REGEXP_IPV4: RegExp;
|
|
86
|
+
declare const REGEXP_IPV6: RegExp;
|
|
87
|
+
declare const REGEXP_PORT: RegExp;
|
|
88
|
+
declare const REGEXP_CHINESE: RegExp;
|
|
89
|
+
declare const REGEXP_POSTAL_CODE: RegExp;
|
|
90
|
+
declare const REGEXP_QQ: RegExp;
|
|
91
|
+
declare const REGEXP_USERNAME: RegExp;
|
|
92
|
+
declare const REGEXP_PASSWORD: RegExp;
|
|
93
|
+
declare const REGEXP_STRONG_PASSWORD: RegExp;
|
|
94
|
+
declare const REGEXP_INTEGER: RegExp;
|
|
95
|
+
declare const REGEXP_POSITIVE_INTEGER: RegExp;
|
|
96
|
+
declare const REGEXP_DECIMAL: RegExp;
|
|
97
|
+
declare const REGEXP_AMOUNT: RegExp;
|
|
98
|
+
declare const regexp: {
|
|
99
|
+
readonly phone: RegExp;
|
|
100
|
+
readonly fixedPhone: RegExp;
|
|
101
|
+
readonly email: RegExp;
|
|
102
|
+
readonly idCard: RegExp;
|
|
103
|
+
readonly bankCard: RegExp;
|
|
104
|
+
readonly passport: RegExp;
|
|
105
|
+
readonly carPlate: RegExp;
|
|
106
|
+
readonly url: RegExp;
|
|
107
|
+
readonly ipv4: RegExp;
|
|
108
|
+
readonly ipv6: RegExp;
|
|
109
|
+
readonly port: RegExp;
|
|
110
|
+
readonly chinese: RegExp;
|
|
111
|
+
readonly postalCode: RegExp;
|
|
112
|
+
readonly qq: RegExp;
|
|
113
|
+
readonly username: RegExp;
|
|
114
|
+
readonly password: RegExp;
|
|
115
|
+
readonly strongPassword: RegExp;
|
|
116
|
+
readonly integer: RegExp;
|
|
117
|
+
readonly positiveInteger: RegExp;
|
|
118
|
+
readonly decimal: RegExp;
|
|
119
|
+
readonly amount: RegExp;
|
|
120
|
+
};
|
|
121
|
+
type RegexpKey = keyof typeof regexp;
|
|
122
|
+
declare function testRegexp(value: string, pattern: RegExp): boolean;
|
|
123
|
+
declare const isPhone: (value: string) => boolean;
|
|
124
|
+
declare const isFixedPhone: (value: string) => boolean;
|
|
125
|
+
declare const isEmail: (value: string) => boolean;
|
|
126
|
+
declare const isIdCard: (value: string) => boolean;
|
|
127
|
+
declare const isBankCard: (value: string) => boolean;
|
|
128
|
+
declare const isPassport: (value: string) => boolean;
|
|
129
|
+
declare const isCarPlate: (value: string) => boolean;
|
|
130
|
+
declare const isUrl: (value: string) => boolean;
|
|
131
|
+
declare const isIpv4: (value: string) => boolean;
|
|
132
|
+
declare const isIpv6: (value: string) => boolean;
|
|
133
|
+
declare const isPort: (value: string) => boolean;
|
|
134
|
+
declare const isChinese: (value: string) => boolean;
|
|
135
|
+
declare const isPostalCode: (value: string) => boolean;
|
|
136
|
+
declare const isQq: (value: string) => boolean;
|
|
137
|
+
declare const isUsername: (value: string) => boolean;
|
|
138
|
+
declare const isPassword: (value: string) => boolean;
|
|
139
|
+
declare const isStrongPassword: (value: string) => boolean;
|
|
140
|
+
declare const isInteger: (value: string) => boolean;
|
|
141
|
+
declare const isPositiveInteger: (value: string) => boolean;
|
|
142
|
+
declare const isDecimal: (value: string) => boolean;
|
|
143
|
+
declare const isAmount: (value: string) => boolean;
|
|
144
|
+
|
|
145
|
+
interface CacheStorage {
|
|
146
|
+
length: number;
|
|
147
|
+
key(index: number): string | null;
|
|
148
|
+
getItem(key: string): string | null;
|
|
149
|
+
setItem(key: string, value: string): void;
|
|
150
|
+
removeItem(key: string): void;
|
|
151
|
+
}
|
|
152
|
+
interface CacheOptions {
|
|
153
|
+
prefix?: string;
|
|
154
|
+
ttl?: number;
|
|
155
|
+
storage?: CacheStorage;
|
|
156
|
+
}
|
|
157
|
+
interface CacheSetOptions {
|
|
158
|
+
ttl?: number;
|
|
159
|
+
}
|
|
160
|
+
interface Cache {
|
|
161
|
+
set<T>(key: string, value: T, options?: CacheSetOptions): void;
|
|
162
|
+
get<T = unknown>(key: string): T | undefined;
|
|
163
|
+
has(key: string): boolean;
|
|
164
|
+
remove(key: string): void;
|
|
165
|
+
clear(): void;
|
|
166
|
+
keys(): string[];
|
|
167
|
+
size(): number;
|
|
168
|
+
}
|
|
169
|
+
declare function createCache(options?: CacheOptions): Cache;
|
|
170
|
+
declare const cache: Cache;
|
|
171
|
+
|
|
172
|
+
interface AesOptions {
|
|
173
|
+
iv?: string;
|
|
174
|
+
mode?: 'CBC' | 'CFB' | 'CTR' | 'ECB' | 'OFB';
|
|
175
|
+
padding?: 'Pkcs7' | 'Iso97971' | 'AnsiX923' | 'Iso10126' | 'ZeroPadding' | 'NoPadding';
|
|
176
|
+
keyMode?: 'utf8' | 'passphrase';
|
|
177
|
+
}
|
|
178
|
+
interface RsaOptions {
|
|
179
|
+
publicKey?: string;
|
|
180
|
+
privateKey?: string;
|
|
181
|
+
}
|
|
182
|
+
interface Sm2Options {
|
|
183
|
+
cipherMode?: 0 | 1;
|
|
184
|
+
}
|
|
185
|
+
interface Sm4Options {
|
|
186
|
+
mode?: 'ecb' | 'cbc';
|
|
187
|
+
iv?: string;
|
|
188
|
+
padding?: 'pkcs#5' | 'pkcs#7' | 'none';
|
|
189
|
+
output?: 'string' | 'array';
|
|
190
|
+
}
|
|
191
|
+
interface CryptoOptions {
|
|
192
|
+
aesKey?: string;
|
|
193
|
+
aesOptions?: AesOptions;
|
|
194
|
+
rsaPublicKey?: string;
|
|
195
|
+
rsaPrivateKey?: string;
|
|
196
|
+
sm2PublicKey?: string;
|
|
197
|
+
sm2PrivateKey?: string;
|
|
198
|
+
sm2Options?: Sm2Options;
|
|
199
|
+
sm4Key?: string;
|
|
200
|
+
sm4Options?: Sm4Options;
|
|
201
|
+
}
|
|
202
|
+
interface CryptoInstance {
|
|
203
|
+
encrypt(value: string, secret?: string): string;
|
|
204
|
+
decrypt(value: string, secret?: string): string;
|
|
205
|
+
encryptAes(value: string, secret?: string): string;
|
|
206
|
+
decryptAes(value: string, secret?: string): string;
|
|
207
|
+
encryptRsa(value: string, publicKey?: string): string;
|
|
208
|
+
decryptRsa(value: string, privateKey?: string): string;
|
|
209
|
+
encryptSm2(value: string, publicKey?: string): string;
|
|
210
|
+
decryptSm2(value: string, privateKey?: string): string;
|
|
211
|
+
encryptSm4(value: string, key?: string): string | number[];
|
|
212
|
+
decryptSm4(value: string | number[], key?: string): string;
|
|
213
|
+
}
|
|
214
|
+
declare function createCrypto(options?: CryptoOptions): CryptoInstance;
|
|
215
|
+
declare function encrypt(value: string, secret: string, options?: AesOptions): string;
|
|
216
|
+
declare function decrypt(value: string, secret: string, options?: AesOptions): string;
|
|
217
|
+
declare function encryptAes(value: string, secret: string, options?: AesOptions): string;
|
|
218
|
+
declare function decryptAes(value: string, secret: string, options?: AesOptions): string;
|
|
219
|
+
declare function encryptRsa(value: string, publicKey: string): string;
|
|
220
|
+
declare function decryptRsa(value: string, privateKey: string): string;
|
|
221
|
+
declare function encryptSm2(value: string, publicKey: string, options?: Sm2Options): string;
|
|
222
|
+
declare function decryptSm2(value: string, privateKey: string, options?: Sm2Options): string;
|
|
223
|
+
declare function encryptSm4(value: string, key: string, options?: Sm4Options): string | number[];
|
|
224
|
+
declare function decryptSm4(value: string | number[], key: string, options?: Sm4Options): string;
|
|
225
|
+
declare function md5(value: string): string;
|
|
226
|
+
declare function sha256(value: string): string;
|
|
227
|
+
declare function toBase64(value: string): string;
|
|
228
|
+
declare function fromBase64(value: string): string;
|
|
229
|
+
|
|
230
|
+
type DateValue = Date | string | number;
|
|
231
|
+
declare function toDate(value: DateValue): Date;
|
|
232
|
+
declare function isValidDate(value: DateValue): boolean;
|
|
233
|
+
declare function formatDate(value: DateValue, pattern?: string): string;
|
|
234
|
+
declare function startOfDay(value: DateValue): Date;
|
|
235
|
+
declare function endOfDay(value: DateValue): Date;
|
|
236
|
+
declare function addDays(value: DateValue, amount: number): Date;
|
|
237
|
+
declare function diffDays(left: DateValue, right: DateValue): number;
|
|
238
|
+
declare function diffHours(left: DateValue, right: DateValue): number;
|
|
239
|
+
declare function fromNow(value: DateValue, now?: DateValue): string;
|
|
240
|
+
|
|
241
|
+
interface FormatMoneyOptions {
|
|
242
|
+
precision?: number;
|
|
243
|
+
symbol?: string;
|
|
244
|
+
thousand?: string;
|
|
245
|
+
decimal?: string;
|
|
246
|
+
}
|
|
247
|
+
interface FormatPercentOptions {
|
|
248
|
+
precision?: number;
|
|
249
|
+
multiplier?: number;
|
|
250
|
+
}
|
|
251
|
+
declare function toFixedSafe(value: number, precision?: number): string;
|
|
252
|
+
declare function formatThousands(value: number | string, separator?: string): string;
|
|
253
|
+
declare function formatMoney(value: number, options?: FormatMoneyOptions): string;
|
|
254
|
+
declare function formatPercent(value: number, options?: FormatPercentOptions): string;
|
|
255
|
+
declare function formatFileSize(bytes: number, precision?: number): string;
|
|
256
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
257
|
+
|
|
258
|
+
type TreeKey = string | number;
|
|
259
|
+
type TreeNode = Record<string, unknown>;
|
|
260
|
+
interface TreeOptions {
|
|
261
|
+
idKey?: string;
|
|
262
|
+
parentKey?: string;
|
|
263
|
+
childrenKey?: string;
|
|
264
|
+
}
|
|
265
|
+
declare function listToTree<T extends TreeNode>(list: T[], options?: TreeOptions): T[];
|
|
266
|
+
declare function treeToList<T extends TreeNode>(tree: T[], options?: Pick<TreeOptions, 'childrenKey'>): T[];
|
|
267
|
+
declare function findTreeNode<T extends TreeNode>(tree: T[], predicate: (node: T) => boolean, options?: Pick<TreeOptions, 'childrenKey'>): T | undefined;
|
|
268
|
+
declare function filterTree<T extends TreeNode>(tree: T[], predicate: (node: T) => boolean, options?: Pick<TreeOptions, 'childrenKey'>): T[];
|
|
269
|
+
declare function getTreePath<T extends TreeNode>(tree: T[], predicate: (node: T) => boolean, options?: Pick<TreeOptions, 'childrenKey'>): T[];
|
|
270
|
+
declare function getTreeLeaves<T extends TreeNode>(tree: T[], options?: Pick<TreeOptions, 'childrenKey'>): T[];
|
|
271
|
+
|
|
272
|
+
interface StorageLike {
|
|
273
|
+
length: number;
|
|
274
|
+
key(index: number): string | null;
|
|
275
|
+
getItem(key: string): string | null;
|
|
276
|
+
setItem(key: string, value: string): void;
|
|
277
|
+
removeItem(key: string): void;
|
|
278
|
+
clear?(): void;
|
|
279
|
+
}
|
|
280
|
+
interface StorageOptions {
|
|
281
|
+
namespace?: string;
|
|
282
|
+
ttl?: number;
|
|
283
|
+
storage?: StorageLike;
|
|
284
|
+
encrypt?: (value: string) => string;
|
|
285
|
+
decrypt?: (value: string) => string;
|
|
286
|
+
}
|
|
287
|
+
interface StorageSetOptions {
|
|
288
|
+
ttl?: number;
|
|
289
|
+
}
|
|
290
|
+
interface StorageInstance {
|
|
291
|
+
set<T>(key: string, value: T, options?: StorageSetOptions): void;
|
|
292
|
+
get<T = unknown>(key: string): T | undefined;
|
|
293
|
+
getRaw(key: string): string | undefined;
|
|
294
|
+
has(key: string): boolean;
|
|
295
|
+
remove(key: string): void;
|
|
296
|
+
clear(): void;
|
|
297
|
+
keys(): string[];
|
|
298
|
+
size(): number;
|
|
299
|
+
}
|
|
300
|
+
declare function createStorage(options?: StorageOptions): StorageInstance;
|
|
301
|
+
declare const localStore: StorageInstance;
|
|
302
|
+
declare const sessionStore: StorageInstance;
|
|
303
|
+
|
|
304
|
+
interface CopyTextOptions {
|
|
305
|
+
onSuccess?: () => void;
|
|
306
|
+
onError?: (error: unknown) => void;
|
|
307
|
+
}
|
|
308
|
+
declare function copyText(text: string, options?: CopyTextOptions): Promise<boolean>;
|
|
309
|
+
|
|
310
|
+
interface DownloadOptions {
|
|
311
|
+
filename?: string;
|
|
312
|
+
mimeType?: string;
|
|
313
|
+
}
|
|
314
|
+
declare function downloadBlob(blob: Blob, options?: DownloadOptions): void;
|
|
315
|
+
declare function downloadText(text: string, filename?: string): void;
|
|
316
|
+
declare function downloadJSON(data: unknown, filename?: string): void;
|
|
317
|
+
interface DownloadStreamOptions extends DownloadOptions {
|
|
318
|
+
onProgress?: (loaded: number, total: number) => void;
|
|
319
|
+
onError?: (error: unknown) => void;
|
|
320
|
+
}
|
|
321
|
+
declare function downloadStream(response: Response, options?: DownloadStreamOptions): Promise<void>;
|
|
322
|
+
|
|
323
|
+
declare function fileToBase64(file: File): Promise<string>;
|
|
324
|
+
declare function base64ToBlob(base64: string, mimeType?: string): Blob;
|
|
325
|
+
declare function getFileExtension(filename: string): string;
|
|
326
|
+
|
|
327
|
+
declare function deepClone<T>(obj: T): T;
|
|
328
|
+
declare function deepMerge<T extends Record<string, unknown>>(target: T, ...sources: Array<Partial<Record<string, unknown>>>): T;
|
|
329
|
+
declare function removeEmptyValues<T extends Record<string, unknown>>(obj: T, options?: {
|
|
330
|
+
removeNull?: boolean;
|
|
331
|
+
removeUndefined?: boolean;
|
|
332
|
+
removeEmptyString?: boolean;
|
|
333
|
+
removeEmptyArray?: boolean;
|
|
334
|
+
removeEmptyObject?: boolean;
|
|
335
|
+
}): Partial<T>;
|
|
336
|
+
declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
337
|
+
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
338
|
+
declare function flatten(obj: Record<string, unknown>, prefix?: string, result?: Record<string, unknown>): Record<string, unknown>;
|
|
339
|
+
declare function unflatten(obj: Record<string, unknown>): Record<string, unknown>;
|
|
340
|
+
|
|
341
|
+
declare function flattenArray<T>(arr: unknown[], depth?: number): T[];
|
|
342
|
+
declare function chunk<T>(arr: T[], size: number): T[][];
|
|
343
|
+
declare function unique<T>(arr: T[]): T[];
|
|
344
|
+
declare function uniqueBy<T>(arr: T[], key: keyof T | ((item: T) => unknown)): T[];
|
|
345
|
+
declare function groupBy<T>(arr: T[], key: keyof T | ((item: T) => unknown)): Record<string, T[]>;
|
|
346
|
+
declare function intersection<T>(arr1: T[], arr2: T[]): T[];
|
|
347
|
+
declare function difference<T>(arr1: T[], arr2: T[]): T[];
|
|
348
|
+
declare function shuffle<T>(arr: T[]): T[];
|
|
349
|
+
declare function sortBy<T>(arr: T[], key: keyof T | ((item: T) => unknown), order?: 'asc' | 'desc'): T[];
|
|
350
|
+
declare function sum(arr: number[]): number;
|
|
351
|
+
declare function average(arr: number[]): number;
|
|
352
|
+
declare function maxBy<T>(arr: T[], key: keyof T | ((item: T) => number)): T | undefined;
|
|
353
|
+
declare function minBy<T>(arr: T[], key: keyof T | ((item: T) => number)): T | undefined;
|
|
354
|
+
declare function moveItem<T>(arr: T[], fromIndex: number, toIndex: number): T[];
|
|
355
|
+
declare function swapItems<T>(arr: T[], index1: number, index2: number): T[];
|
|
356
|
+
|
|
357
|
+
declare function isEmpty(str: unknown): boolean;
|
|
358
|
+
declare function isNotEmpty(str: unknown): boolean;
|
|
359
|
+
declare function capitalize(str: string): string;
|
|
360
|
+
declare function uncapitalize(str: string): string;
|
|
361
|
+
declare function camelCase(str: string): string;
|
|
362
|
+
declare function pascalCase(str: string): string;
|
|
363
|
+
declare function kebabCase(str: string): string;
|
|
364
|
+
declare function snakeCase(str: string): string;
|
|
365
|
+
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
366
|
+
declare function generateUUID(): string;
|
|
367
|
+
declare function escapeHtml(str: string): string;
|
|
368
|
+
declare function unescapeHtml(str: string): string;
|
|
369
|
+
declare function parseQueryString(url: string): Record<string, string>;
|
|
370
|
+
declare function stringifyQueryString(params: Record<string, string | number | boolean | undefined | null>): string;
|
|
371
|
+
declare function buildUrl(baseUrl: string, params: Record<string, string | number | boolean | undefined | null>): string;
|
|
372
|
+
|
|
373
|
+
interface DebounceOptions {
|
|
374
|
+
wait?: number;
|
|
375
|
+
leading?: boolean;
|
|
376
|
+
trailing?: boolean;
|
|
377
|
+
}
|
|
378
|
+
type AnyFunction = (...args: any[]) => any;
|
|
379
|
+
interface DebouncedFunc<T extends AnyFunction> {
|
|
380
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
381
|
+
cancel: () => void;
|
|
382
|
+
flush: () => ReturnType<T> | undefined;
|
|
383
|
+
pending: () => boolean;
|
|
384
|
+
}
|
|
385
|
+
declare function debounce<T extends AnyFunction>(func: T, options?: DebounceOptions): DebouncedFunc<T>;
|
|
386
|
+
interface ThrottleOptions {
|
|
387
|
+
wait?: number;
|
|
388
|
+
leading?: boolean;
|
|
389
|
+
trailing?: boolean;
|
|
390
|
+
}
|
|
391
|
+
interface ThrottledFunc<T extends AnyFunction> {
|
|
392
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
393
|
+
cancel: () => void;
|
|
394
|
+
flush: () => ReturnType<T> | undefined;
|
|
395
|
+
pending: () => boolean;
|
|
396
|
+
}
|
|
397
|
+
declare function throttle<T extends AnyFunction>(func: T, options?: ThrottleOptions): ThrottledFunc<T>;
|
|
398
|
+
|
|
399
|
+
declare function get<T = any>(obj: any, path: string | string[], defaultValue?: T): T | undefined;
|
|
400
|
+
|
|
401
|
+
export { type AesOptions, type Cache, type CacheOptions, type CacheSetOptions, type CacheStorage, type CopyTextOptions, type CryptoInstance, type CryptoOptions, type DateValue, type DebounceOptions, type DebouncedFunc, type DownloadOptions, type DownloadStreamOptions, type FormatMoneyOptions, type FormatPercentOptions, type MaskAccountOptions, type MaskAddressOptions, type MaskBankCardOptions, type MaskCarPlateOptions, type MaskEmailOptions, type MaskFixedPhoneOptions, type MaskIdCardOptions, type MaskIpOptions, type MaskNameOptions, type MaskOptions, type MaskPassportOptions, type MaskPhoneOptions, type MaskSecretOptions, REGEXP_AMOUNT, REGEXP_BANK_CARD, REGEXP_CAR_PLATE, REGEXP_CHINESE, REGEXP_DECIMAL, REGEXP_EMAIL, REGEXP_FIXED_PHONE, REGEXP_ID_CARD, REGEXP_INTEGER, REGEXP_IPV4, REGEXP_IPV6, REGEXP_PASSPORT, REGEXP_PASSWORD, REGEXP_PHONE, REGEXP_PORT, REGEXP_POSITIVE_INTEGER, REGEXP_POSTAL_CODE, REGEXP_QQ, REGEXP_STRONG_PASSWORD, REGEXP_URL, REGEXP_USERNAME, type RegexpKey, type RsaOptions, type Sm2Options, type Sm4Options, type StorageInstance, type StorageLike, type StorageOptions, type StorageSetOptions, type ThrottleOptions, type ThrottledFunc, type TreeKey, type TreeNode, type TreeOptions, type UniversalMaskOptions, addDays, average, base64ToBlob, buildUrl, cache, camelCase, capitalize, chunk, clamp, copyText, createCache, createCrypto, createStorage, debounce, decrypt, decryptAes, decryptRsa, decryptSm2, decryptSm4, deepClone, deepMerge, diffDays, diffHours, difference, downloadBlob, downloadJSON, downloadStream, downloadText, encrypt, encryptAes, encryptRsa, encryptSm2, encryptSm4, endOfDay, escapeHtml, fileToBase64, filterTree, findTreeNode, flatten, flattenArray, formatDate, formatFileSize, formatMoney, formatPercent, formatThousands, fromBase64, fromNow, generateUUID, get, getFileExtension, getTreeLeaves, getTreePath, groupBy, intersection, isAmount, isBankCard, isCarPlate, isChinese, isDecimal, isEmail, isEmpty, isFixedPhone, isIdCard, isInteger, isIpv4, isIpv6, isNotEmpty, isPassport, isPassword, isPhone, isPort, isPositiveInteger, isPostalCode, isQq, isStrongPassword, isUrl, isUsername, isValidDate, kebabCase, listToTree, localStore, mask, maskAccount, maskAddress, maskBankCard, maskCarPlate, maskEmail, maskFixedPhone, maskIdCard, maskIp, maskName, maskPassport, maskPhone, maskSecret, maxBy, md5, minBy, moveItem, omit, parseQueryString, pascalCase, pick, regexp, removeEmptyValues, sessionStore, sha256, shuffle, snakeCase, sortBy, startOfDay, stringifyQueryString, sum, swapItems, testRegexp, throttle, toBase64, toDate, toFixedSafe, treeToList, truncate, uncapitalize, unescapeHtml, unflatten, unique, uniqueBy };
|