sculp-js 1.18.1 → 1.18.2
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/cjs/array.js +1 -1
- package/dist/cjs/async.js +1 -1
- package/dist/cjs/base64.js +1 -1
- package/dist/cjs/clipboard.js +1 -1
- package/dist/cjs/cloneDeep.js +1 -1
- package/dist/cjs/cookie.js +1 -1
- package/dist/cjs/date.js +1 -1
- package/dist/cjs/dom.js +1 -1
- package/dist/cjs/download.js +1 -1
- package/dist/cjs/file.js +1 -1
- package/dist/cjs/func.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/isEqual.js +1 -1
- package/dist/cjs/math.js +1 -1
- package/dist/cjs/number.js +1 -1
- package/dist/cjs/object.js +1 -1
- package/dist/cjs/path.js +1 -1
- package/dist/cjs/qs.js +1 -1
- package/dist/cjs/random.js +1 -1
- package/dist/cjs/string.js +1 -1
- package/dist/cjs/tooltip.js +1 -1
- package/dist/cjs/tree.js +1 -1
- package/dist/cjs/type.js +1 -1
- package/dist/cjs/unicodeToolkit.js +17 -14
- package/dist/cjs/unique.js +1 -1
- package/dist/cjs/url.js +1 -1
- package/dist/cjs/validator.js +1 -1
- package/dist/cjs/variable.js +1 -1
- package/dist/cjs/watermark.js +1 -1
- package/dist/esm/array.js +1 -1
- package/dist/esm/async.js +1 -1
- package/dist/esm/base64.js +1 -1
- package/dist/esm/clipboard.js +1 -1
- package/dist/esm/cloneDeep.js +1 -1
- package/dist/esm/cookie.js +1 -1
- package/dist/esm/date.js +1 -1
- package/dist/esm/dom.js +1 -1
- package/dist/esm/download.js +1 -1
- package/dist/esm/file.js +1 -1
- package/dist/esm/func.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/isEqual.js +1 -1
- package/dist/esm/math.js +1 -1
- package/dist/esm/number.js +1 -1
- package/dist/esm/object.js +1 -1
- package/dist/esm/path.js +1 -1
- package/dist/esm/qs.js +1 -1
- package/dist/esm/random.js +1 -1
- package/dist/esm/string.js +1 -1
- package/dist/esm/tooltip.js +1 -1
- package/dist/esm/tree.js +1 -1
- package/dist/esm/type.js +1 -1
- package/dist/esm/unicodeToolkit.js +17 -14
- package/dist/esm/unique.js +1 -1
- package/dist/esm/url.js +1 -1
- package/dist/esm/validator.js +1 -1
- package/dist/esm/variable.js +1 -1
- package/dist/esm/watermark.js +1 -1
- package/dist/types/unicodeToolkit.d.ts +16 -13
- package/dist/umd/index.min.js +1 -1
- package/package.json +9 -8
- package/dist/sculp-js.d.ts +0 -1515
- package/dist/types/tsdoc-metadata.json +0 -11
package/dist/sculp-js.d.ts
DELETED
|
@@ -1,1515 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 数值安全加法
|
|
3
|
-
* @param arg1 数值1
|
|
4
|
-
* @param arg2 数值2
|
|
5
|
-
*/
|
|
6
|
-
export declare const add: (arg1: number, arg2: number) => number;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 给元素增加样式名
|
|
10
|
-
* @param {HTMLElement} el
|
|
11
|
-
* @param {string} classNames
|
|
12
|
-
*/
|
|
13
|
-
export declare function addClass(el: HTMLElement, classNames: string): void;
|
|
14
|
-
|
|
15
|
-
/** 任意数组 */
|
|
16
|
-
export declare type AnyArray = any[];
|
|
17
|
-
|
|
18
|
-
/** 任意函数 */
|
|
19
|
-
export declare type AnyFunc<R = any> = (...args: any[]) => R;
|
|
20
|
-
|
|
21
|
-
/** 任意对象 */
|
|
22
|
-
export declare type AnyObject = Record<string | number, any>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 遍历数组,返回 false 中断遍历(支持continue和break操作)
|
|
26
|
-
*
|
|
27
|
-
* @param {ArrayLike<V>} array
|
|
28
|
-
* @param {(val: V, idx: number) => any} iterator 迭代函数, 返回值为true时continue, 返回值为false时break
|
|
29
|
-
* @param {boolean} reverse 是否倒序
|
|
30
|
-
* @returns {*}
|
|
31
|
-
*/
|
|
32
|
-
export declare function arrayEach<V>(array: ArrayLike<V>, iterator: (val: V, idx: number, arr: ArrayLike<V>) => boolean | void, reverse?: boolean): void;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 异步遍历数组,返回 false 中断遍历
|
|
36
|
-
* @param {ArrayLike<V>} array 数组
|
|
37
|
-
* @param {(val: V, idx: number) => Promise<any>} iterator 支持Promise类型的回调函数
|
|
38
|
-
* @param {boolean} reverse 是否反向遍历
|
|
39
|
-
* @example
|
|
40
|
-
* 使用范例如下:
|
|
41
|
-
* const start = async () => {
|
|
42
|
-
* await arrayEachAsync(result, async (item) => {
|
|
43
|
-
* await request(item);
|
|
44
|
-
* count++;
|
|
45
|
-
* })
|
|
46
|
-
* console.log('发送次数', count);
|
|
47
|
-
* }
|
|
48
|
-
|
|
49
|
-
* for await...of 使用范例如下
|
|
50
|
-
* const loadImages = async (images) => {
|
|
51
|
-
* for await (const item of images) {
|
|
52
|
-
* await request(item);
|
|
53
|
-
* count++;
|
|
54
|
-
* }
|
|
55
|
-
* }
|
|
56
|
-
*/
|
|
57
|
-
export declare function arrayEachAsync<V>(array: ArrayLike<V>, iterator: (val: V, idx: number) => Promise<any> | any, reverse?: boolean): Promise<void>;
|
|
58
|
-
|
|
59
|
-
/** 取出数组元素 */
|
|
60
|
-
export declare type ArrayElements<A> = A extends Array<infer R> ? R : never;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 插入到目标位置之前
|
|
64
|
-
* @param {AnyArray} array
|
|
65
|
-
* @param {number} start
|
|
66
|
-
* @param {number} to
|
|
67
|
-
* @returns {*}
|
|
68
|
-
*/
|
|
69
|
-
export declare function arrayInsertBefore(array: AnyArray, start: number, to: number): void;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 判断一个对象是否为类数组
|
|
73
|
-
*
|
|
74
|
-
* @param any
|
|
75
|
-
* @returns {boolean}
|
|
76
|
-
*/
|
|
77
|
-
export declare function arrayLike(any: unknown): boolean;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* 数组删除指定项目
|
|
81
|
-
* @param {V[]} array
|
|
82
|
-
* @param {(val: V, idx: number) => boolean} expect
|
|
83
|
-
* @returns {V[]}
|
|
84
|
-
*/
|
|
85
|
-
export declare function arrayRemove<V>(array: V[], expect: (val: V, idx: number) => boolean): V[];
|
|
86
|
-
|
|
87
|
-
/** 异步回调函数 */
|
|
88
|
-
export declare type AsyncCallback = {
|
|
89
|
-
successCallback?: Function;
|
|
90
|
-
failCallback?: Function;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 异步遍历
|
|
95
|
-
* @ref https://github.com/Kevnz/async-tools/blob/master/src/mapper.js
|
|
96
|
-
* @ref https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/@@iterator
|
|
97
|
-
* @param {Array<T>} list
|
|
98
|
-
* @param {(val: T, idx: number, list: ArrayLike<T>) => Promise<R>} mapper
|
|
99
|
-
* @param {number} concurrency 并发数量,默认无限
|
|
100
|
-
* @returns {Promise<R[]>}
|
|
101
|
-
*/
|
|
102
|
-
export declare function asyncMap<T, R>(list: Array<T>, mapper: (val: T, idx: number, list: Array<T>) => Promise<R>, concurrency?: number): Promise<R[]>;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 将base64编码的字符串转换为原始字符串,包括对中文内容的处理(高性能,且支持Web、Node、小程序等任意平台)
|
|
106
|
-
* @param base64 base64编码的字符串
|
|
107
|
-
* @returns 原始字符串,包括中文内容
|
|
108
|
-
*/
|
|
109
|
-
export declare function b64decode(base64: string): string;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* 将原始字符串,包括中文内容,转换为base64编码的字符串(高性能,且支持Web、Node、小程序等任意平台)
|
|
113
|
-
* @param rawStr 原始字符串,包括中文内容
|
|
114
|
-
* @returns base64编码的字符串
|
|
115
|
-
*/
|
|
116
|
-
export declare function b64encode(rawStr: string): string;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 计算向前或向后N天的具体日期
|
|
120
|
-
* @param {DateValue} originDate - 参考日期
|
|
121
|
-
* @param {number} n - 正数:向后推算;负数:向前推算
|
|
122
|
-
* @param {string} sep - 日期格式的分隔符
|
|
123
|
-
* @returns {string} 计算后的目标日期
|
|
124
|
-
*/
|
|
125
|
-
export declare function calculateDate(originDate: DateValue, n: number, sep?: string): string;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 计算向前或向后N天的具体日期时间
|
|
129
|
-
* @param {DateValue} originDateTime - 参考日期时间
|
|
130
|
-
* @param {number} n - 正数:向后推算;负数:向前推算
|
|
131
|
-
* @param {string} dateSep - 日期分隔符
|
|
132
|
-
* @param {string} timeSep - 时间分隔符
|
|
133
|
-
* @returns {string} 转换后的目标日期时间
|
|
134
|
-
*/
|
|
135
|
-
export declare function calculateDateTime(originDateTime: DateValue, n: number, dateSep?: string, timeSep?: string): string;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 将指定属性变为可选
|
|
139
|
-
*
|
|
140
|
-
* Change the specified properties to optional
|
|
141
|
-
*/
|
|
142
|
-
export declare type ChangeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 将指定属性变为必填
|
|
146
|
-
*
|
|
147
|
-
* Change the specified properties to required
|
|
148
|
-
*/
|
|
149
|
-
export declare type ChangeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 将除指定属性外的所有属性变为必填
|
|
153
|
-
*
|
|
154
|
-
* Change all properties except the specified properties to required
|
|
155
|
-
*/
|
|
156
|
-
export declare type ChangeRequiredExcept<T, K extends keyof T> = Required<Omit<T, K>> & Partial<Pick<T, K>>;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* 选择本地文件
|
|
160
|
-
* @param {string} accept 上传的文件类型,用于过滤
|
|
161
|
-
* @param {Function} changeCb 选择文件回调
|
|
162
|
-
* @returns {HTMLInputElement}
|
|
163
|
-
*/
|
|
164
|
-
export declare function chooseLocalFile(accept: string, changeCb: (FileList: any) => any): void;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* 深拷贝堪称完全体 即:任何类型的数据都会被深拷贝
|
|
168
|
-
*
|
|
169
|
-
* 包含对null、原始值、对象循环引用的处理
|
|
170
|
-
*
|
|
171
|
-
* 对Map、Set、ArrayBuffer、Date、RegExp、Array、Object及原型链属性方法执行深拷贝
|
|
172
|
-
* @param {T} source
|
|
173
|
-
* @param {WeakMap} map
|
|
174
|
-
* @returns {T}
|
|
175
|
-
*/
|
|
176
|
-
export declare function cloneDeep<T>(source: T, map?: WeakMap<any, any>): T;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Web端:等比例压缩图片批量处理 (小于minFileSizeKB:50,不压缩), 支持压缩全景图或长截图
|
|
180
|
-
*
|
|
181
|
-
* 1. 默认根据图片原始size及宽高适当地调整quality、width、height
|
|
182
|
-
* 2. 可指定压缩的图片质量 quality(若不指定则根据原始图片大小来计算), 来适当调整width、height
|
|
183
|
-
* 3. 可指定压缩的图片最大宽高 maxSize(若不指定则根据原始图片宽高来计算), 满足大屏幕图片展示的场景
|
|
184
|
-
*
|
|
185
|
-
* @param {File | FileList} file 图片或图片数组
|
|
186
|
-
* @param {ICompressOptions} options 压缩图片配置项,default: {mime:'image/jpeg', minFileSizeKB: 50}
|
|
187
|
-
* @returns {Promise<ICompressImgResult | ICompressImgResult[] | null>}
|
|
188
|
-
*/
|
|
189
|
-
export declare function compressImg(file: File | FileList, options?: ICompressOptions): Promise<ICompressImgResult | ICompressImgResult[] | null>;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* 删除单个 cookie
|
|
193
|
-
* @param name cookie 名称
|
|
194
|
-
*/
|
|
195
|
-
export declare const cookieDel: (name: string) => void;
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* 获取cookie
|
|
199
|
-
* @param {string} name
|
|
200
|
-
* @returns {string}
|
|
201
|
-
*/
|
|
202
|
-
export declare function cookieGet(name: string): string;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* 设置 cookie
|
|
206
|
-
* @param {string} name
|
|
207
|
-
* @param {string} value
|
|
208
|
-
* @param {number | Date} [maxAge]
|
|
209
|
-
*/
|
|
210
|
-
export declare function cookieSet(name: string, value: string, maxAge?: number | Date): void;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* 复制文本,优先使用navigator.clipboard,仅在安全上下文(HTTPS/localhost)下生效,若不支持则回退使用execCommand方式
|
|
214
|
-
* @param {string} text
|
|
215
|
-
* @param {CopyTextOptions} options 可选参数:成功回调successCallback、失败回调failCallback、容器元素container
|
|
216
|
-
* (默认document.body, 当不支持clipboard时必须传复制按钮元素,包裹模拟选择操作的临时元素,
|
|
217
|
-
* 解决脱离文档流的元素无法复制的问题,如Modal内复制操作)
|
|
218
|
-
*/
|
|
219
|
-
export declare function copyText(text: string, options?: CopyTextOptions): void;
|
|
220
|
-
|
|
221
|
-
declare type CopyTextOptions = AsyncCallback & {
|
|
222
|
-
container?: HTMLElement;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 根据URL下载文件(解决跨域a.download不生效问题)
|
|
227
|
-
*
|
|
228
|
-
* 可定制下载成功的状态码status(浏览器原生状态码)
|
|
229
|
-
*
|
|
230
|
-
* 支持下载操作成功、失败后的回调
|
|
231
|
-
* @param {string} url
|
|
232
|
-
* @param {string} filename
|
|
233
|
-
* @param {CrossOriginDownloadParams} options
|
|
234
|
-
*/
|
|
235
|
-
export declare function crossOriginDownload(url: string, filename: string, options?: CrossOriginDownloadParams): void;
|
|
236
|
-
|
|
237
|
-
declare type CrossOriginDownloadParams = AsyncCallback & {
|
|
238
|
-
successCode?: number;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
export declare interface DateObj {
|
|
242
|
-
[propName: string]: string;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* 解析为Date对象
|
|
247
|
-
* @param {DateValue} value - 可以是数值、字符串或 Date 对象
|
|
248
|
-
* @returns {Date} - 转换后的目标Date
|
|
249
|
-
*/
|
|
250
|
-
export declare function dateParse(value: DateValue): Date;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* 将日期转换为一天的结束时间,即23点59分59秒999毫秒
|
|
254
|
-
* @param {DateValue} value
|
|
255
|
-
* @returns {Date}
|
|
256
|
-
*/
|
|
257
|
-
export declare function dateToEnd(value: DateValue): Date;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* 格式化为日期对象(带自定义格式化模板)
|
|
261
|
-
* @param {DateValue} value 可以是数值、字符串或 Date 对象
|
|
262
|
-
* @param {string} [format] 模板,默认是 YYYY-MM-DD HH:mm:ss,模板字符:
|
|
263
|
-
* - YYYY:年
|
|
264
|
-
* - yyyy: 年
|
|
265
|
-
* - MM:月
|
|
266
|
-
* - DD:日
|
|
267
|
-
* - dd: 日
|
|
268
|
-
* - HH:时(24 小时制)
|
|
269
|
-
* - hh:时(12 小时制)
|
|
270
|
-
* - mm:分
|
|
271
|
-
* - ss:秒
|
|
272
|
-
* - SSS:毫秒
|
|
273
|
-
* @returns {string}
|
|
274
|
-
*/
|
|
275
|
-
/**
|
|
276
|
-
* 将日期转换为一天的开始时间,即0点0分0秒0毫秒
|
|
277
|
-
* @param {DateValue} value
|
|
278
|
-
* @returns {Date}
|
|
279
|
-
*/
|
|
280
|
-
export declare function dateToStart(value: DateValue): Date;
|
|
281
|
-
|
|
282
|
-
export declare type DateValue = number | string | Date;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* 防抖函数
|
|
286
|
-
* 当函数被连续调用时,该函数并不执行,只有当其全部停止调用超过一定时间后才执行1次。
|
|
287
|
-
* 例如:上电梯的时候,大家陆陆续续进来,电梯的门不会关上,只有当一段时间都没有人上来,电梯才会关门。
|
|
288
|
-
* @param {F} func
|
|
289
|
-
* @param {number} wait
|
|
290
|
-
* @returns {DebounceFunc<F>}
|
|
291
|
-
*/
|
|
292
|
-
export declare const debounce: <F extends AnyFunc>(func: F, wait?: number) => DebounceFunc<F>;
|
|
293
|
-
|
|
294
|
-
export declare interface DebounceFunc<F extends AnyFunc> {
|
|
295
|
-
(...args: Parameters<F>): void;
|
|
296
|
-
cancel: () => void;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Compare source array and target array, return diff result (added / removed).
|
|
301
|
-
*
|
|
302
|
-
* - If `getKey` is not provided:
|
|
303
|
-
* - Primitive values (string | number | symbol) will be used as keys directly.
|
|
304
|
-
* - If `getKey` is provided:
|
|
305
|
-
* - It will be used to extract unique keys from items.
|
|
306
|
-
*
|
|
307
|
-
* @template T
|
|
308
|
-
* @param source - Source array (original data)
|
|
309
|
-
* @param target - Target array (new data)
|
|
310
|
-
* @param getKey - Optional function to get unique key
|
|
311
|
-
*
|
|
312
|
-
* @returns DiffResult<T>
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* ```ts
|
|
316
|
-
* diffArray([1, 2, 3], [2, 3, 4])
|
|
317
|
-
* // => { added: [4], removed: [1] }
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* @example
|
|
321
|
-
* ```ts
|
|
322
|
-
* diffArray(['a', 'b'], ['b', 'c'])
|
|
323
|
-
* // => { added: ['c'], removed: ['a'] }
|
|
324
|
-
* ```
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```ts
|
|
328
|
-
* diffArray(
|
|
329
|
-
* [{ id: 1 }, { id: 2 }],
|
|
330
|
-
* [{ id: 2 }, { id: 3 }],
|
|
331
|
-
* item => item.id
|
|
332
|
-
* )
|
|
333
|
-
* // => { added: [{ id: 3 }], removed: [{ id: 1 }] }
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
export declare function diffArray<T>(source: readonly T[], target: readonly T[], getKey?: GetKey<T>): DiffResult<T>;
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Diff result type
|
|
340
|
-
*/
|
|
341
|
-
export declare interface DiffResult<T> {
|
|
342
|
-
/** Items that exist in target but not in source */
|
|
343
|
-
added: T[];
|
|
344
|
-
/** Items that exist in source but not in target */
|
|
345
|
-
removed: T[];
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* 数值安全除法
|
|
350
|
-
* @param arg1 数值1
|
|
351
|
-
* @param arg2 数值2
|
|
352
|
-
*/
|
|
353
|
-
export declare const divide: (arg1: number, arg2: number) => number;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* 将大文件对象通过 A 链接的方式下载
|
|
357
|
-
* @param {Blob} blob
|
|
358
|
-
* @param {string} filename
|
|
359
|
-
* @param {Function} callback
|
|
360
|
-
*/
|
|
361
|
-
export declare function downloadBlob(blob: Blob, filename: string, callback?: Function): void;
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* 将指定数据格式通过 A 链接的方式下载
|
|
365
|
-
* @param {AnyObject | AnyObject[]} data
|
|
366
|
-
* @param {FileType} fileType 支持 json/csv/xls/xlsx 四种格式
|
|
367
|
-
* @param {string} filename
|
|
368
|
-
* @param {string[]} [headers]
|
|
369
|
-
*/
|
|
370
|
-
export declare function downloadData(data: AnyObject | AnyObject[], fileType: FileType, filename: string, headers?: string[]): void;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* 通过 A 链接的方式下载
|
|
374
|
-
* @param {string} href
|
|
375
|
-
* @param {string} filename
|
|
376
|
-
* @param {Function} callback
|
|
377
|
-
*/
|
|
378
|
-
export declare function downloadHref(href: string, filename: string, callback?: Function): void;
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* 通过打开新窗口的方式下载
|
|
382
|
-
* @param {string} url
|
|
383
|
-
* @param {LooseParams} params
|
|
384
|
-
*/
|
|
385
|
-
export declare function downloadURL(url: string, params?: LooseParams): void;
|
|
386
|
-
|
|
387
|
-
export declare const EMAIL_REGEX: RegExp;
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* 转义所有特殊字符
|
|
391
|
-
* @param {string} str 原字符串
|
|
392
|
-
* reference: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_expressions
|
|
393
|
-
* @returns string
|
|
394
|
-
*/
|
|
395
|
-
export declare function escapeRegExp(str: string): string;
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* 在指定作用域中执行代码
|
|
399
|
-
* @param {string} code 要执行的代码(需包含 return 语句或表达式)
|
|
400
|
-
* @param {Object} scope 作用域对象(键值对形式的变量环境)
|
|
401
|
-
* @returns 代码执行结果
|
|
402
|
-
*
|
|
403
|
-
* @example
|
|
404
|
-
* // 测试用例 1: 基本变量访问
|
|
405
|
-
* executeInScope("return a + b;", { a: 1, b: 2 });
|
|
406
|
-
* // 3
|
|
407
|
-
*
|
|
408
|
-
* // 测试用例 2: 支持复杂表达式和运算
|
|
409
|
-
* executeInScope(
|
|
410
|
-
* "return Array.from({ length: 3 }, (_, i) => base + i);",
|
|
411
|
-
* { base: 100 }
|
|
412
|
-
* );
|
|
413
|
-
* // [100, 101, 102]
|
|
414
|
-
*
|
|
415
|
-
* // 支持外传函数作用域执行
|
|
416
|
-
* const scope = {
|
|
417
|
-
* $: {
|
|
418
|
-
* fun: {
|
|
419
|
-
* time: {
|
|
420
|
-
* now: function () {
|
|
421
|
-
* return new Date();
|
|
422
|
-
* },
|
|
423
|
-
* },
|
|
424
|
-
* },
|
|
425
|
-
* },
|
|
426
|
-
* };
|
|
427
|
-
* executeInScope("return $.fun.time.now()", scope)
|
|
428
|
-
*/
|
|
429
|
-
export declare function executeInScope(code: string, scope?: Record<string, any>): any;
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* 使用execCommand方式复制文本
|
|
433
|
-
* @param text
|
|
434
|
-
* @param options
|
|
435
|
-
*/
|
|
436
|
-
export declare function fallbackCopyText(text: string, options?: CopyTextOptions): void;
|
|
437
|
-
|
|
438
|
-
export declare type FileType = 'json' | 'csv' | 'xls' | 'xlsx';
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* 树过滤函数, 可用于过滤Array和NodeList类型的数据
|
|
442
|
-
* @param {ArrayLike<V>} tree 树形数据
|
|
443
|
-
* @param {Function} predicate 断言函数
|
|
444
|
-
* @param {options} options 支持定制子元素名称、反向遍历、广度优先遍历,默认{
|
|
445
|
-
childField: 'children',
|
|
446
|
-
reverse: false,
|
|
447
|
-
breadthFirst: false,
|
|
448
|
-
isDomNode: false,
|
|
449
|
-
}
|
|
450
|
-
* @returns {V[]}
|
|
451
|
-
*/
|
|
452
|
-
export declare function filterDeep<V>(tree: ArrayLike<V>, predicate: (val: V, index: number, currentArr: ArrayLike<V>, tree: ArrayLike<V>, parent: V | null, level: number) => boolean | void, options?: {
|
|
453
|
-
childField?: string;
|
|
454
|
-
reverse?: boolean;
|
|
455
|
-
breadthFirst?: boolean;
|
|
456
|
-
isDomNode?: boolean;
|
|
457
|
-
}): V[];
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* 树查找函数, 可用于查找Array和NodeList类型的数据
|
|
461
|
-
* @param {ArrayLike<V>} tree 树形数据
|
|
462
|
-
* @param {Function} predicate 断言函数
|
|
463
|
-
* @param {options} options 支持定制子元素名称、反向遍历、广度优先遍历,默认{
|
|
464
|
-
childField: 'children',
|
|
465
|
-
reverse: false,
|
|
466
|
-
breadthFirst: false,
|
|
467
|
-
isDomNode: false,
|
|
468
|
-
}
|
|
469
|
-
* @returns {V|null}
|
|
470
|
-
*/
|
|
471
|
-
export declare function findDeep<V>(tree: ArrayLike<V>, predicate: (val: V, index: number, currentArr: ArrayLike<V>, tree: ArrayLike<V>, parent: V | null, level: number) => boolean | void, options?: {
|
|
472
|
-
childField?: string;
|
|
473
|
-
reverse?: boolean;
|
|
474
|
-
breadthFirst?: boolean;
|
|
475
|
-
isDomNode?: boolean;
|
|
476
|
-
}): V | null;
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* 树形结构转扁平化
|
|
480
|
-
* @param {any[]} treeList
|
|
481
|
-
* @param {IFieldOptions} options 定制id字段名,子元素字段名,父元素字段名,默认
|
|
482
|
-
* { keyField: 'key', childField: 'children', pidField: 'pid' }
|
|
483
|
-
* @returns {any[]}
|
|
484
|
-
*/
|
|
485
|
-
export declare function flatTree(treeList: any[], options?: IFieldOptions): any[];
|
|
486
|
-
|
|
487
|
-
export declare interface Fn<T = any, R = T> {
|
|
488
|
-
(...arg: T[]): R;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* 树遍历函数(支持continue和break操作), 可用于遍历Array和NodeList类型的数据
|
|
493
|
-
* @param {ArrayLike<V>} tree 树形数据
|
|
494
|
-
* @param {Function} iterator 迭代函数, 返回值为true时continue, 返回值为false时break
|
|
495
|
-
* @param {options} options 支持定制子元素名称、反向遍历、广度优先遍历,默认{
|
|
496
|
-
childField: 'children',
|
|
497
|
-
reverse: false,
|
|
498
|
-
breadthFirst: false,
|
|
499
|
-
isDomNode: false,
|
|
500
|
-
}
|
|
501
|
-
* @returns {*}
|
|
502
|
-
*/
|
|
503
|
-
export declare function forEachDeep<V>(tree: ArrayLike<V>, iterator: (val: V, index: number, currentArr: ArrayLike<V>, tree: ArrayLike<V>, parent: V | null, level: number) => boolean | void, options?: {
|
|
504
|
-
childField?: string;
|
|
505
|
-
reverse?: boolean;
|
|
506
|
-
breadthFirst?: boolean;
|
|
507
|
-
isDomNode?: boolean;
|
|
508
|
-
}): void;
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* 格式化为日期对象(带自定义格式化模板)
|
|
512
|
-
* @param {Date} value - 可以是数值、字符串或 Date 对象
|
|
513
|
-
* @param {string} [format] - 模板,默认是 YYYY-MM-DD HH:mm:ss,模板字符:
|
|
514
|
-
* - YYYY:年
|
|
515
|
-
* - yyyy: 年
|
|
516
|
-
* - MM:月
|
|
517
|
-
* - DD:日
|
|
518
|
-
* - dd: 日
|
|
519
|
-
* - HH:时(24 小时制)
|
|
520
|
-
* - mm:分
|
|
521
|
-
* - ss:秒
|
|
522
|
-
* - SSS:毫秒
|
|
523
|
-
* - ww: 周
|
|
524
|
-
* @returns {string} 格式化后的日期字符串
|
|
525
|
-
*/
|
|
526
|
-
export declare function formatDate(value: DateValue, format?: string): string;
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* 将数字格式化成千位分隔符显示的字符串
|
|
530
|
-
* @param {number|string} num 数字
|
|
531
|
-
* @param {number} decimals 格式化成指定小数位精度的参数
|
|
532
|
-
* @returns {string}
|
|
533
|
-
*/
|
|
534
|
-
declare function formatNumber(num: number | string, decimals?: number): string;
|
|
535
|
-
export { formatNumber as formatMoney }
|
|
536
|
-
export { formatNumber }
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* 扁平化数组转换成树
|
|
540
|
-
* @param {any[]} list
|
|
541
|
-
* @param {IFieldOptions} options 定制id字段名,子元素字段名,父元素字段名,默认
|
|
542
|
-
* { keyField: 'key', childField: 'children', pidField: 'pid' }
|
|
543
|
-
* @returns {any[]}
|
|
544
|
-
*/
|
|
545
|
-
export declare function formatTree(list: any[], options?: IFieldOptions): any[];
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* 模糊搜索函数,返回包含搜索字符的节点及其祖先节点, 适用于树型组件的字符过滤功能
|
|
549
|
-
* 以下搜索条件二选一,按先后优先级处理:
|
|
550
|
-
* 1. 过滤函数filter, 返回true/false
|
|
551
|
-
* 2. 匹配关键词,支持是否启用忽略大小写来判断
|
|
552
|
-
*
|
|
553
|
-
* 有以下特性:
|
|
554
|
-
* 1. 可配置removeEmptyChild字段,来决定是否移除搜索结果中的空children字段
|
|
555
|
-
* 2. 若无任何过滤条件或keyword模式匹配且keyword为空串,返回原对象;其他情况返回新数组
|
|
556
|
-
* @param {V[]} nodes
|
|
557
|
-
* @param {IFilterCondition} filterCondition
|
|
558
|
-
* @param {ISearchTreeOpts} options 默认配置项 {
|
|
559
|
-
childField: 'children',
|
|
560
|
-
nameField: 'name',
|
|
561
|
-
removeEmptyChild: false,
|
|
562
|
-
ignoreCase: true
|
|
563
|
-
}
|
|
564
|
-
* @returns {V[]}
|
|
565
|
-
*/
|
|
566
|
-
export declare function fuzzySearchTree<V>(nodes: V[], filterCondition: IFilterCondition<V>, options?: ISearchTreeOpts): V[];
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* canvas 实现 水印, 具备防删除功能
|
|
570
|
-
* @param {ICanvasWM} canvasWM
|
|
571
|
-
* @example genCanvasWM({ content: 'QQMusicFE' })
|
|
572
|
-
*/
|
|
573
|
-
export declare function genCanvasWM(content?: string, canvasWM?: ICanvasWM): void;
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* 获取元素样式属性的计算值
|
|
577
|
-
* @param {HTMLElement} el
|
|
578
|
-
* @param {string} property
|
|
579
|
-
* @param {boolean} reNumber
|
|
580
|
-
* @returns {string|number}
|
|
581
|
-
*/
|
|
582
|
-
export declare function getComputedCssVal(el: HTMLElement, property: string, reNumber?: boolean): string | number;
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* 获取全局变量
|
|
586
|
-
* @param {string | number | symbol} key
|
|
587
|
-
* @param val
|
|
588
|
-
*/
|
|
589
|
-
export declare function getGlobal<T>(key: string | number | symbol): T | void;
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Get unique key function
|
|
593
|
-
*/
|
|
594
|
-
export declare type GetKey<T> = (item: T) => string | number | symbol;
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* 字符串的像素宽度
|
|
598
|
-
* @param {string} str 目标字符串
|
|
599
|
-
* @param {number} fontSize 字符串字体大小
|
|
600
|
-
* @param {boolean} isRemove 计算后是否移除创建的dom元素
|
|
601
|
-
* @returns {*}
|
|
602
|
-
*/
|
|
603
|
-
export declare function getStrWidthPx(str: string, fontSize?: number, isRemove?: boolean): number;
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* 获取元素样式
|
|
607
|
-
* @param {HTMLElement} el 元素
|
|
608
|
-
* @param {string} key
|
|
609
|
-
* @returns {string}
|
|
610
|
-
*/
|
|
611
|
-
export declare function getStyle(el: HTMLElement, key: string): string;
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* 自定义title提示功能的mouseenter事件句柄
|
|
615
|
-
* @param {ITooltipParams} param
|
|
616
|
-
* @returns {*}
|
|
617
|
-
*/
|
|
618
|
-
declare function handleMouseEnter({ rootContainer, title, event, bgColor, color }: ITooltipParams): void;
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* 移除提示文案dom的事件句柄
|
|
622
|
-
* @param {string} rootContainer
|
|
623
|
-
* @returns {*}
|
|
624
|
-
*/
|
|
625
|
-
declare function handleMouseLeave(rootContainer?: HTMLElement | string): void;
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* 判断元素是否包含某个样式名
|
|
629
|
-
* @param {HTMLElement} el
|
|
630
|
-
* @param {string} className
|
|
631
|
-
* @returns {boolean}
|
|
632
|
-
*/
|
|
633
|
-
export declare function hasClass(el: HTMLElement, className: string): boolean;
|
|
634
|
-
|
|
635
|
-
export declare const HEX_POOL: string;
|
|
636
|
-
|
|
637
|
-
export declare const HTTP_URL_REGEX: RegExp;
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* Converting file size in bytes to human-readable string
|
|
641
|
-
* reference: https://zh.wikipedia.org/wiki/%E5%8D%83%E5%AD%97%E8%8A%82
|
|
642
|
-
* @param {number | string} num bytes Number in Bytes
|
|
643
|
-
* @param {IHumanFileSizeOptions} options default: { decimals = 0, si = false, separator = ' ' }
|
|
644
|
-
* si: True to use metric (SI) units, aka powers of 1000, the units is
|
|
645
|
-
* ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'].
|
|
646
|
-
* False to use binary (IEC), aka powers of 1024, the units is
|
|
647
|
-
* ['Byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
|
|
648
|
-
* @returns
|
|
649
|
-
*/
|
|
650
|
-
export declare function humanFileSize(num: number | string, options?: IHumanFileSizeOptions): string;
|
|
651
|
-
|
|
652
|
-
export declare interface ICanvasWM {
|
|
653
|
-
rootContainer?: HTMLElement | string;
|
|
654
|
-
width?: string;
|
|
655
|
-
height?: string;
|
|
656
|
-
textAlign?: CanvasTextAlign;
|
|
657
|
-
textBaseline?: CanvasTextBaseline;
|
|
658
|
-
font?: string;
|
|
659
|
-
fillStyle?: string;
|
|
660
|
-
rotate?: number;
|
|
661
|
-
zIndex?: number;
|
|
662
|
-
watermarkId?: string;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
export declare interface ICompressImgResult {
|
|
666
|
-
file: File;
|
|
667
|
-
bufferArray?: Uint8Array;
|
|
668
|
-
origin?: File;
|
|
669
|
-
beforeSrc?: string;
|
|
670
|
-
afterSrc?: string;
|
|
671
|
-
beforeKB?: number;
|
|
672
|
-
afterKB?: number;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
export declare interface ICompressOptions {
|
|
676
|
-
/** 压缩质量 0 ~ 1 之间*/
|
|
677
|
-
quality?: number;
|
|
678
|
-
/** 图片类型 */
|
|
679
|
-
mime?: ImageType;
|
|
680
|
-
maxSize?: number;
|
|
681
|
-
minFileSizeKB?: number;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
export declare type IdLike = number | string;
|
|
685
|
-
|
|
686
|
-
export declare interface IFieldOptions {
|
|
687
|
-
keyField: string;
|
|
688
|
-
childField: string;
|
|
689
|
-
pidField: string;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
export declare interface IFilterCondition<V> {
|
|
693
|
-
keyword?: string;
|
|
694
|
-
filter?: (args: V) => boolean;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
declare interface IHumanFileSizeOptions {
|
|
698
|
-
decimals?: number;
|
|
699
|
-
si?: boolean;
|
|
700
|
-
separator?: string;
|
|
701
|
-
baseUnit?: string;
|
|
702
|
-
maxUnit?: string;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
declare type ImageType = 'image/jpeg' | 'image/png' | 'image/webp';
|
|
706
|
-
|
|
707
|
-
declare interface INumberAbbr {
|
|
708
|
-
ratio?: number;
|
|
709
|
-
decimals?: number;
|
|
710
|
-
separator?: string;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
export declare const IPV4_REGEX: RegExp;
|
|
714
|
-
|
|
715
|
-
export declare const IPV6_REGEX: RegExp;
|
|
716
|
-
|
|
717
|
-
export declare const isArray: (any: unknown) => any is unknown[];
|
|
718
|
-
|
|
719
|
-
export declare const isBigInt: (any: unknown) => any is bigint;
|
|
720
|
-
|
|
721
|
-
export declare const isBoolean: (any: unknown) => any is boolean;
|
|
722
|
-
|
|
723
|
-
export declare const isDate: (any: unknown) => any is Date;
|
|
724
|
-
|
|
725
|
-
/**
|
|
726
|
-
* 判断字符串是否为数字,例如六位数字短信验证码(093031)
|
|
727
|
-
* @param {string} value
|
|
728
|
-
* @returns {boolean}
|
|
729
|
-
*/
|
|
730
|
-
export declare const isDigit: (value: string) => boolean;
|
|
731
|
-
|
|
732
|
-
export declare interface ISearchTreeOpts {
|
|
733
|
-
childField: string;
|
|
734
|
-
nameField: string;
|
|
735
|
-
removeEmptyChild: boolean;
|
|
736
|
-
ignoreCase: boolean;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* 判断字符串是否为邮箱格式,不对邮箱真实性做验证,如域名是否正确等
|
|
741
|
-
* @param {string} value
|
|
742
|
-
* @returns {boolean}
|
|
743
|
-
*/
|
|
744
|
-
export declare const isEmail: (value: string) => boolean;
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* Checks if `value` is an empty object, collection, map, or set.
|
|
748
|
-
*
|
|
749
|
-
* Objects are considered empty if they have no own enumerable string keyed
|
|
750
|
-
* properties.
|
|
751
|
-
*
|
|
752
|
-
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
|
753
|
-
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
|
754
|
-
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
|
755
|
-
*
|
|
756
|
-
* @param {*} value The value to check.
|
|
757
|
-
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
|
758
|
-
* @example
|
|
759
|
-
*
|
|
760
|
-
* isEmpty(null);
|
|
761
|
-
* // => true
|
|
762
|
-
*
|
|
763
|
-
* isEmpty(true);
|
|
764
|
-
* // => true
|
|
765
|
-
*
|
|
766
|
-
* isEmpty(1);
|
|
767
|
-
* // => true
|
|
768
|
-
*
|
|
769
|
-
* isEmpty([1, 2, 3]);
|
|
770
|
-
* // => false
|
|
771
|
-
*
|
|
772
|
-
* isEmpty({ 'a': 1 });
|
|
773
|
-
* // => false
|
|
774
|
-
*/
|
|
775
|
-
export declare function isEmpty(value: any): boolean;
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* @description 深度比较两个值是否相等(支持循环引用、各种内置对象类型)
|
|
779
|
-
* @performance
|
|
780
|
-
* 1. 快速路径:引用相等和 NaN 检查
|
|
781
|
-
* 2. 快速失败:优先比较 constructor、length 和 size
|
|
782
|
-
* 3. 惰性 getTag:仅在构造函数一致且非基础类型时获取详细类型
|
|
783
|
-
* * @example
|
|
784
|
-
* isEqual({ a: [1, 2] }, { a: [1, 2] }) // true
|
|
785
|
-
* isEqual(new Date(0), new Date(0)) // true
|
|
786
|
-
* isEqual(() => {}, () => {}) // false (不同引用)
|
|
787
|
-
* * @param value 要比较的值
|
|
788
|
-
* @param other 另一个要比较的值
|
|
789
|
-
* @returns {boolean} 是否深度相等
|
|
790
|
-
*/
|
|
791
|
-
export declare function isEqual(value: any, other: any): boolean;
|
|
792
|
-
|
|
793
|
-
export declare const isError: (any: unknown) => any is Error;
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* 判断字符串是否为浮点数,即必须有小数点的有理数
|
|
797
|
-
* @param {string} value
|
|
798
|
-
* @returns {boolean}
|
|
799
|
-
*/
|
|
800
|
-
export declare const isFloat: (value: string) => boolean;
|
|
801
|
-
|
|
802
|
-
/**
|
|
803
|
-
* 判断是否为函数
|
|
804
|
-
* @param {unknown} any
|
|
805
|
-
* @returns {boolean}
|
|
806
|
-
*/
|
|
807
|
-
export declare const isFunction: (any: unknown) => any is Function;
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* 判断字符串是否为身份证号码格式
|
|
811
|
-
* @param {string} value
|
|
812
|
-
* @returns {boolean}
|
|
813
|
-
*/
|
|
814
|
-
export declare const isIdNo: (value: string) => boolean;
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* 判断字符串是否为整数(自然数),即 ...,-3,-2,-1,0,1,2,3,...
|
|
818
|
-
* @param {string} value
|
|
819
|
-
* @returns {boolean}
|
|
820
|
-
*/
|
|
821
|
-
export declare const isInteger: (value: string) => boolean;
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* 判断字符串是否为 IPV4 格式,不对 ip 真实性做验证
|
|
825
|
-
* @param {string} value
|
|
826
|
-
* @returns {boolean}
|
|
827
|
-
*/
|
|
828
|
-
export declare const isIpV4: (value: string) => boolean;
|
|
829
|
-
|
|
830
|
-
/**
|
|
831
|
-
* 判断字符串是否为 IPV6 格式,不对 ip 真实性做验证
|
|
832
|
-
* @param {string} value
|
|
833
|
-
* @returns {boolean}
|
|
834
|
-
*/
|
|
835
|
-
export declare const isIpV6: (value: string) => boolean;
|
|
836
|
-
|
|
837
|
-
/**
|
|
838
|
-
* 判断一个字符串是否为有效的 JSON, 若有效则返回有效的JSON对象,否则false
|
|
839
|
-
* @param {string} str
|
|
840
|
-
* @returns {Object | boolean}
|
|
841
|
-
*/
|
|
842
|
-
export declare function isJsonString(str: string): Object | boolean;
|
|
843
|
-
|
|
844
|
-
declare const isNaN_2: (any: unknown) => any is number;
|
|
845
|
-
export { isNaN_2 as isNaN }
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
* Checks if `value` is an NodeList object
|
|
849
|
-
*/
|
|
850
|
-
export declare function isNodeList(value: any): boolean;
|
|
851
|
-
|
|
852
|
-
export declare const isNull: (any: unknown) => any is null;
|
|
853
|
-
|
|
854
|
-
declare function isNullOrUnDef(val: unknown): val is null | undefined;
|
|
855
|
-
export { isNullOrUnDef }
|
|
856
|
-
export { isNullOrUnDef as isNullish }
|
|
857
|
-
|
|
858
|
-
export declare const isNumber: (any: unknown) => any is number;
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* 判断字符串是否为正确数值,包括整数和浮点数
|
|
862
|
-
* @param {string} value
|
|
863
|
-
* @returns {boolean}
|
|
864
|
-
*/
|
|
865
|
-
export declare const isNumerical: (value: string) => boolean;
|
|
866
|
-
|
|
867
|
-
export declare const isObject: (any: unknown) => any is Record<string, unknown>;
|
|
868
|
-
|
|
869
|
-
/**
|
|
870
|
-
* 判断字符串是否为宽松手机格式,即首位为 1 的 11 位数字都属于手机号
|
|
871
|
-
* @param {string} value
|
|
872
|
-
* @returns {boolean}
|
|
873
|
-
*/
|
|
874
|
-
export declare const isPhone: (value: string) => boolean;
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* 判断对象是否为纯对象
|
|
878
|
-
* @param {object} obj
|
|
879
|
-
* @returns {boolean}
|
|
880
|
-
*/
|
|
881
|
-
export declare const isPlainObject: (obj: unknown) => boolean;
|
|
882
|
-
|
|
883
|
-
export declare const isPrimitive: (any: unknown) => boolean;
|
|
884
|
-
|
|
885
|
-
export declare const isRegExp: (any: unknown) => any is RegExp;
|
|
886
|
-
|
|
887
|
-
export declare const isString: (any: unknown) => any is string;
|
|
888
|
-
|
|
889
|
-
export declare const isSymbol: (any: unknown) => any is symbol;
|
|
890
|
-
|
|
891
|
-
export declare const isUndefined: (any: unknown) => any is undefined;
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* 判断字符串是否为 url 格式,支持 http、https、ftp 协议,支持域名或者 ipV4
|
|
895
|
-
* @param {string} value
|
|
896
|
-
* @returns {boolean}
|
|
897
|
-
*/
|
|
898
|
-
export declare const isUrl: (url: string, includeFtp?: boolean) => boolean;
|
|
899
|
-
|
|
900
|
-
export declare const isValidDate: (any: unknown) => any is Date;
|
|
901
|
-
|
|
902
|
-
/**
|
|
903
|
-
* 自定义的 tooltip, 支持鼠标移动动悬浮提示
|
|
904
|
-
* @Desc 自定义的tooltip方法, 支持拖动悬浮提示
|
|
905
|
-
* Created by chendeqiao on 2017/5/8.
|
|
906
|
-
* @example
|
|
907
|
-
* <span onmouseleave="handleMouseLeave('#root')"
|
|
908
|
-
* onmousemove="handleMouseEnter({rootContainer: '#root', title: 'title content', event: event})"
|
|
909
|
-
* onmouseenter="handleMouseEnter({rootContainer:'#root', title: 'title content', event: event})">
|
|
910
|
-
* title content
|
|
911
|
-
* </span>
|
|
912
|
-
*/
|
|
913
|
-
declare interface ITooltipParams {
|
|
914
|
-
rootContainer: HTMLElement | string;
|
|
915
|
-
title: string;
|
|
916
|
-
event: PointerEvent | MouseEvent;
|
|
917
|
-
bgColor?: string;
|
|
918
|
-
color?: string;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
export declare type ITreeConf = Omit<IFieldOptions, 'pidField'>;
|
|
922
|
-
|
|
923
|
-
export declare interface LooseParams<T = LooseParamValue> {
|
|
924
|
-
[key: string]: T | Array<T>;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
export declare type LooseParamValue = string | number | boolean | Date | null | undefined;
|
|
928
|
-
|
|
929
|
-
/**
|
|
930
|
-
* 创建一个新数组, 深度优先遍历的Map函数(支持continue和break操作), 可用于insert tree item 和 remove tree item
|
|
931
|
-
*
|
|
932
|
-
* 可遍历任何带有 length 属性和数字键的类数组对象
|
|
933
|
-
* @param {ArrayLike<V>} tree 树形数据
|
|
934
|
-
* @param {Function} iterator 迭代函数, 返回值为true时continue, 返回值为false时break
|
|
935
|
-
* @param {options} options 支持定制子元素名称、反向遍历,默认{
|
|
936
|
-
childField: 'children',
|
|
937
|
-
reverse: false,
|
|
938
|
-
}
|
|
939
|
-
* @returns {any[]} 新的一棵树
|
|
940
|
-
*/
|
|
941
|
-
export declare function mapDeep<T>(tree: T[], iterator: (val: T, index: number, currentArr: T[], tree: T[], parent: T | null, level: number) => {
|
|
942
|
-
[k: string | number]: any;
|
|
943
|
-
} | boolean, options?: {
|
|
944
|
-
childField?: string;
|
|
945
|
-
reverse?: boolean;
|
|
946
|
-
breadthFirst?: boolean;
|
|
947
|
-
}): any[];
|
|
948
|
-
|
|
949
|
-
/**
|
|
950
|
-
* 数值安全乘法
|
|
951
|
-
* @param arg1 数值1
|
|
952
|
-
* @param arg2 数值2
|
|
953
|
-
*/
|
|
954
|
-
export declare const multiply: (arg1: number, arg2: number) => number;
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* 将数字转换为携带单位的字符串
|
|
958
|
-
* @param {number | string} num
|
|
959
|
-
* @param {Array<string>} units
|
|
960
|
-
* @param {INumberAbbr} options default: { ratio: 1000, decimals: 0, separator: ' ' }
|
|
961
|
-
* @returns {string}
|
|
962
|
-
*/
|
|
963
|
-
export declare const numberAbbr: (num: number | string, units: Array<string>, options?: INumberAbbr) => string;
|
|
964
|
-
|
|
965
|
-
/**
|
|
966
|
-
* 将十进制转换成任意进制
|
|
967
|
-
* @param {number | string} decimal 十进制数值或字符串,可以是任意长度,会使用大数进行计算
|
|
968
|
-
* @param {string} [hexPool] 进制池,默认 62 进制
|
|
969
|
-
* @returns {string}
|
|
970
|
-
*/
|
|
971
|
-
export declare function numberToHex(decimal: number | string, hexPool?: string): string;
|
|
972
|
-
|
|
973
|
-
declare type NumberType = number | string;
|
|
974
|
-
|
|
975
|
-
/**
|
|
976
|
-
* 对象合并,返回原始对象
|
|
977
|
-
* @param {ObjectAssignItem} source
|
|
978
|
-
* @param {ObjectAssignItem | undefined} targets
|
|
979
|
-
* @returns {R}
|
|
980
|
-
*/
|
|
981
|
-
declare function objectAssign<R = AnyObject | AnyArray>(source: ObjectAssignItem, ...targets: (ObjectAssignItem | undefined)[]): R;
|
|
982
|
-
export { objectAssign }
|
|
983
|
-
export { objectAssign as objectMerge }
|
|
984
|
-
|
|
985
|
-
export declare type ObjectAssignItem = AnyObject | AnyArray;
|
|
986
|
-
|
|
987
|
-
/**
|
|
988
|
-
* 遍历对象,返回 false 中断遍历
|
|
989
|
-
* @param {O} obj
|
|
990
|
-
* @param {(val: O[keyof O], key: keyof O) => (boolean | void)} iterator
|
|
991
|
-
*/
|
|
992
|
-
export declare function objectEach<O extends AnyObject>(obj: O, iterator: (val: O[keyof O], key: Extract<keyof O, string>) => any): void;
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* 异步遍历对象,返回 false 中断遍历
|
|
996
|
-
* @param {O} obj
|
|
997
|
-
* @param {(val: O[keyof O], key: keyof O) => (boolean | void)} iterator
|
|
998
|
-
*/
|
|
999
|
-
export declare function objectEachAsync<O extends AnyObject>(obj: O, iterator: (val: O[keyof O], key: Extract<keyof O, string>) => Promise<any> | any): Promise<void>;
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* 对象填充
|
|
1003
|
-
* @param {Partial<R>} source
|
|
1004
|
-
* @param {Partial<R>} target
|
|
1005
|
-
* @param {(s: Partial<R>, t: Partial<R>, key: keyof R) => boolean} fillable
|
|
1006
|
-
* @returns {R}
|
|
1007
|
-
*/
|
|
1008
|
-
export declare function objectFill<R extends AnyObject = AnyObject>(source: Partial<R>, target: Partial<R>, fillable?: (s: typeof source, t: typeof target, key: keyof R) => boolean): R;
|
|
1009
|
-
|
|
1010
|
-
/**
|
|
1011
|
-
* 获取对象/数组指定层级下的属性值(现在可用ES6+的可选链?.来替代)
|
|
1012
|
-
* @param {AnyObject} obj
|
|
1013
|
-
* @param {string} path
|
|
1014
|
-
* @param {boolean} strict
|
|
1015
|
-
* @returns
|
|
1016
|
-
*/
|
|
1017
|
-
export declare function objectGet(obj: AnyObject | AnyArray | undefined, path: string, strict?: boolean): {
|
|
1018
|
-
p: any | undefined;
|
|
1019
|
-
k: string | undefined;
|
|
1020
|
-
v: any | undefined;
|
|
1021
|
-
};
|
|
1022
|
-
|
|
1023
|
-
/**
|
|
1024
|
-
* 判断对象内是否有该静态属性
|
|
1025
|
-
* @param {object} obj
|
|
1026
|
-
* @param {string} key
|
|
1027
|
-
* @returns {boolean}
|
|
1028
|
-
*/
|
|
1029
|
-
export declare function objectHas<T extends AnyObject>(obj: T, key: keyof T): boolean;
|
|
1030
|
-
|
|
1031
|
-
/**
|
|
1032
|
-
* 对象映射
|
|
1033
|
-
* @param {O} obj
|
|
1034
|
-
* @param {(val: O[keyof O], key: Extract<keyof O, string>) => any} iterator
|
|
1035
|
-
* @returns {Record<Extract<keyof O, string>, T>}
|
|
1036
|
-
*/
|
|
1037
|
-
export declare function objectMap<O extends AnyObject, T>(obj: O, iterator: (val: O[keyof O], key: Extract<keyof O, string>) => any): Record<Extract<keyof O, string>, T>;
|
|
1038
|
-
|
|
1039
|
-
/**
|
|
1040
|
-
* 对象去除
|
|
1041
|
-
* @param {O} obj
|
|
1042
|
-
* @param {K} keys
|
|
1043
|
-
* @returns {Pick<O, ArrayElements<K>>}
|
|
1044
|
-
*/
|
|
1045
|
-
export declare function objectOmit<O extends AnyObject, K extends Extract<keyof O, string>[]>(obj: O, keys: K): Omit<O, ArrayElements<K>>;
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
* 对象提取
|
|
1049
|
-
* @param {O} obj
|
|
1050
|
-
* @param {K} keys
|
|
1051
|
-
* @returns {Pick<O, ArrayElements<K>>}
|
|
1052
|
-
*/
|
|
1053
|
-
export declare function objectPick<O extends AnyObject, K extends Extract<keyof O, string>[]>(obj: O, keys: K): Pick<O, ArrayElements<K>>;
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1056
|
-
* 单次函数
|
|
1057
|
-
* @param {AnyFunc} func
|
|
1058
|
-
* @returns {AnyFunc}
|
|
1059
|
-
*/
|
|
1060
|
-
export declare const once: <F extends AnyFunc = AnyFunc>(func: F) => OnceFunc<F>;
|
|
1061
|
-
|
|
1062
|
-
export declare interface OnceFunc<F extends AnyFunc> {
|
|
1063
|
-
(...args: Parameters<F>): ReturnType<F>;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
export declare interface Params<T = string | number> {
|
|
1067
|
-
[key: string]: T | Array<T>;
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
/**
|
|
1071
|
-
* 解析URL查询参数
|
|
1072
|
-
* @param {string} searchStr
|
|
1073
|
-
* @returns {Record<string, string | string[]>}
|
|
1074
|
-
*/
|
|
1075
|
-
export declare function parseQueryParams(searchStr?: string): Record<string, string | string[]>;
|
|
1076
|
-
|
|
1077
|
-
/**
|
|
1078
|
-
* 解析字符串的插值变量
|
|
1079
|
-
* @param {string} str 字符串
|
|
1080
|
-
* @param {string} leftMatchSymbol 变量左侧匹配符号,默认:{
|
|
1081
|
-
* @param {string} rightMatchSymbol 变量右侧匹配符号,默认:}
|
|
1082
|
-
* @returns string[]
|
|
1083
|
-
* @example
|
|
1084
|
-
*
|
|
1085
|
-
* default match symbol {} same as /{\s*([^{}\s]*)\s*}/g
|
|
1086
|
-
*/
|
|
1087
|
-
export declare function parseVarFromString(str: string, leftMatchSymbol?: string, rightMatchSymbol?: string): string[];
|
|
1088
|
-
|
|
1089
|
-
export declare type PartialDeep<T> = {
|
|
1090
|
-
[P in keyof T]?: PartialDeep<T[P]>;
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
/**
|
|
1094
|
-
* 路径合并
|
|
1095
|
-
* @param {string} from
|
|
1096
|
-
* @param {string} to
|
|
1097
|
-
* @returns {string}
|
|
1098
|
-
*/
|
|
1099
|
-
export declare const pathJoin: (from: string, ...to: string[]) => string;
|
|
1100
|
-
|
|
1101
|
-
/**
|
|
1102
|
-
* 标准化路径
|
|
1103
|
-
* @param {string} path
|
|
1104
|
-
* @returns {string}
|
|
1105
|
-
*/
|
|
1106
|
-
export declare const pathNormalize: (path: string) => string;
|
|
1107
|
-
|
|
1108
|
-
export declare const PHONE_REGEX: RegExp;
|
|
1109
|
-
|
|
1110
|
-
export declare interface PromiseFn<T = any, R = T> {
|
|
1111
|
-
(...arg: T[]): Promise<R>;
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
/**
|
|
1115
|
-
* 解析查询参数,内部使用的是浏览器内置的 URLSearchParams 进行处理
|
|
1116
|
-
* @param {string} queryString
|
|
1117
|
-
* @returns {Params}
|
|
1118
|
-
*/
|
|
1119
|
-
export declare function qsParse(queryString: string): Params;
|
|
1120
|
-
|
|
1121
|
-
/**
|
|
1122
|
-
* 字符化查询对象,内部使用的是浏览器内置的 URLSearchParams 进行处理
|
|
1123
|
-
* @param {LooseParams} query
|
|
1124
|
-
* @param {Replacer} replacer
|
|
1125
|
-
* @returns {string}
|
|
1126
|
-
*/
|
|
1127
|
-
export declare function qsStringify(query: LooseParams, replacer?: Replacer): string;
|
|
1128
|
-
|
|
1129
|
-
/**
|
|
1130
|
-
* 随机整数
|
|
1131
|
-
* @param {number} min
|
|
1132
|
-
* @param {number} max
|
|
1133
|
-
* @returns {number}
|
|
1134
|
-
*/
|
|
1135
|
-
export declare const randomNumber: (min: number, max: number) => number;
|
|
1136
|
-
|
|
1137
|
-
export declare interface RandomString {
|
|
1138
|
-
(length: number, pool: string): string;
|
|
1139
|
-
(length: number): string;
|
|
1140
|
-
(pool: string): string;
|
|
1141
|
-
(): string;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
/**
|
|
1145
|
-
* 随机字符串
|
|
1146
|
-
* @param {number | string} length
|
|
1147
|
-
* @param {string} pool
|
|
1148
|
-
* @returns {string}
|
|
1149
|
-
*/
|
|
1150
|
-
export declare const randomString: RandomString;
|
|
1151
|
-
|
|
1152
|
-
/**
|
|
1153
|
-
* 优先浏览器原生能力获取 UUID v4
|
|
1154
|
-
* @returns {string}
|
|
1155
|
-
*/
|
|
1156
|
-
export declare function randomUuid(): string;
|
|
1157
|
-
|
|
1158
|
-
/**
|
|
1159
|
-
* 给元素移除样式名
|
|
1160
|
-
* @param {HTMLElement} el
|
|
1161
|
-
* @param {string} classNames
|
|
1162
|
-
*/
|
|
1163
|
-
export declare function removeClass(el: HTMLElement, classNames: string): void;
|
|
1164
|
-
|
|
1165
|
-
export declare type Replacer = (value: LooseParamValue) => string | null;
|
|
1166
|
-
|
|
1167
|
-
/**
|
|
1168
|
-
* 替换字符串中的插值变量
|
|
1169
|
-
* @param {string} sourceStr
|
|
1170
|
-
* @param {Record<string, any>} targetObj
|
|
1171
|
-
* @param {string} leftMatchSymbol 变量左侧匹配符号,默认:{
|
|
1172
|
-
* @param {string} rightMatchSymbol 变量右侧匹配符号,默认:}
|
|
1173
|
-
* @returns string
|
|
1174
|
-
*/
|
|
1175
|
-
export declare function replaceVarFromString(sourceStr: string, targetObj: Record<string, any>, leftMatchSymbol?: string, rightMatchSymbol?: string): string;
|
|
1176
|
-
|
|
1177
|
-
/**
|
|
1178
|
-
* Execute a promise safely
|
|
1179
|
-
*
|
|
1180
|
-
* @param { Promise } promise
|
|
1181
|
-
* @param { Object= } errorExt - Additional Information you can pass safeAwait the err object
|
|
1182
|
-
* @return { Promise }
|
|
1183
|
-
* @example
|
|
1184
|
-
* async function asyncTaskWithCb(cb) {
|
|
1185
|
-
let err, user, savedTask, notification;
|
|
1186
|
-
|
|
1187
|
-
[ err, user ] = await safeAwait(UserModel.findById(1));
|
|
1188
|
-
if(!user) return cb('No user found');
|
|
1189
|
-
|
|
1190
|
-
[ err, savedTask ] = await safeAwait(TaskModel({userId: user.id, name: 'Demo Task'}));
|
|
1191
|
-
if(err) return cb('Error occurred while saving task')
|
|
1192
|
-
|
|
1193
|
-
cb(null, savedTask);
|
|
1194
|
-
}
|
|
1195
|
-
*/
|
|
1196
|
-
export declare function safeAwait<T, U = Error>(promise: Promise<T>, errorExt?: object): Promise<[U, undefined] | [null, T]>;
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* 在树中找到 id 为某个值的节点,并返回上游的所有父级节点
|
|
1200
|
-
*
|
|
1201
|
-
* @param {ArrayLike<T>} tree - 树形数据
|
|
1202
|
-
* @param {number | string} nodeId - 目标元素ID
|
|
1203
|
-
* @param {ITreeConf} options - 迭代配置项, 默认:{ children = 'children', id = 'id' }
|
|
1204
|
-
* @returns {[(number | string)[], V[]]} - 由parentId...childId, parentObject-childObject组成的二维数组
|
|
1205
|
-
*/
|
|
1206
|
-
export declare function searchTreeById<V>(tree: ArrayLike<V>, nodeId: IdLike, options?: ITreeConf): [(number | string)[], ArrayLike<V>[]];
|
|
1207
|
-
|
|
1208
|
-
/**
|
|
1209
|
-
* Programmatically select the text of a HTML element
|
|
1210
|
-
*
|
|
1211
|
-
* @param {HTMLElement} element The element whose text you wish to select
|
|
1212
|
-
* @returns
|
|
1213
|
-
*/
|
|
1214
|
-
export declare function select(element: HTMLElement): any;
|
|
1215
|
-
|
|
1216
|
-
/**
|
|
1217
|
-
* 设置全局变量
|
|
1218
|
-
* @param {string | number | symbol} key
|
|
1219
|
-
* @param val
|
|
1220
|
-
*/
|
|
1221
|
-
export declare function setGlobal(key: string | number | symbol, val?: any): void;
|
|
1222
|
-
|
|
1223
|
-
export declare interface SetStyle {
|
|
1224
|
-
(el: HTMLElement, key: string, val: string): void;
|
|
1225
|
-
(el: HTMLElement, style: Style): void;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
/**
|
|
1229
|
-
* 设置元素样式
|
|
1230
|
-
* @param {HTMLElement} el
|
|
1231
|
-
* @param {string | Style} key
|
|
1232
|
-
* @param {string} val
|
|
1233
|
-
*/
|
|
1234
|
-
export declare const setStyle: SetStyle;
|
|
1235
|
-
|
|
1236
|
-
export declare const STRING_ARABIC_NUMERALS = "0123456789";
|
|
1237
|
-
|
|
1238
|
-
export declare const STRING_LOWERCASE_ALPHA = "abcdefghijklmnopqrstuvwxyz";
|
|
1239
|
-
|
|
1240
|
-
export declare const STRING_POOL: string;
|
|
1241
|
-
|
|
1242
|
-
export declare const STRING_UPPERCASE_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
1243
|
-
|
|
1244
|
-
/**
|
|
1245
|
-
* 字符串赋值
|
|
1246
|
-
* @example
|
|
1247
|
-
* ```js
|
|
1248
|
-
* stringAssign('My name is ${user}.', { user: 'zhangsan' });
|
|
1249
|
-
* // => "My name is zhangsan."
|
|
1250
|
-
* ```
|
|
1251
|
-
* @param {string} template
|
|
1252
|
-
* @param {AnyObject} data
|
|
1253
|
-
* @returns {string}
|
|
1254
|
-
*/
|
|
1255
|
-
export declare const stringAssign: (template: string, data: AnyObject) => string;
|
|
1256
|
-
|
|
1257
|
-
/**
|
|
1258
|
-
* 将字符串转换为驼峰格式
|
|
1259
|
-
* @param {string} string
|
|
1260
|
-
* @param {boolean} [bigger] 是否大写第一个字母
|
|
1261
|
-
* @returns {string}
|
|
1262
|
-
*/
|
|
1263
|
-
export declare function stringCamelCase(string: string, bigger?: boolean): string;
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
* 字符串编码 HTML
|
|
1267
|
-
* @example
|
|
1268
|
-
* ```js
|
|
1269
|
-
* stringEscapeHtml('<b>You & Me speak "xixi"</b>')
|
|
1270
|
-
* // => "<b>You & Me speak "xixi"</b>"
|
|
1271
|
-
* ```
|
|
1272
|
-
* @param {string} html
|
|
1273
|
-
* @returns {string}
|
|
1274
|
-
*/
|
|
1275
|
-
export declare const stringEscapeHtml: (html: string) => string;
|
|
1276
|
-
|
|
1277
|
-
/**
|
|
1278
|
-
* 字符串填充
|
|
1279
|
-
* @param {number} length
|
|
1280
|
-
* @param {string} value
|
|
1281
|
-
* @returns {string}
|
|
1282
|
-
*/
|
|
1283
|
-
export declare const stringFill: (length: number, value?: string) => string;
|
|
1284
|
-
|
|
1285
|
-
/**
|
|
1286
|
-
* 字符串格式化
|
|
1287
|
-
* @example
|
|
1288
|
-
* ```js
|
|
1289
|
-
* stringFormat("My name is %s.", "zhangsan")
|
|
1290
|
-
* // => "My name is zhangsan."
|
|
1291
|
-
* ```
|
|
1292
|
-
* @param {string} string 字符串模板,使用 %s 表示字符串,%d 表示数值,%o 表示对象,%% 表示百分号,参考 console.log
|
|
1293
|
-
* @param args
|
|
1294
|
-
* @returns {string}
|
|
1295
|
-
*/
|
|
1296
|
-
export declare function stringFormat(string: string, ...args: Array<unknown>): string;
|
|
1297
|
-
|
|
1298
|
-
/**
|
|
1299
|
-
* 将字符串转换为连字格式
|
|
1300
|
-
* @param {string} string
|
|
1301
|
-
* @param {string} [separator] 分隔符,默认是"-"(短横线)
|
|
1302
|
-
* @returns {string}
|
|
1303
|
-
*/
|
|
1304
|
-
export declare function stringKebabCase(string: string, separator?: string): string;
|
|
1305
|
-
|
|
1306
|
-
/**
|
|
1307
|
-
* Correct the given number to specifying significant digits.
|
|
1308
|
-
*
|
|
1309
|
-
* @param num The input number
|
|
1310
|
-
* @param precision An integer specifying the number of significant digits
|
|
1311
|
-
*
|
|
1312
|
-
* @example strip(0.09999999999999998) === 0.1 // true
|
|
1313
|
-
*/
|
|
1314
|
-
export declare function strip(num: NumberType, precision?: number): number;
|
|
1315
|
-
|
|
1316
|
-
export declare interface Style {
|
|
1317
|
-
[propName: string]: string | number;
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
/**
|
|
1321
|
-
* 数值安全减法
|
|
1322
|
-
* @param arg1 数值1
|
|
1323
|
-
* @param arg2 数值2
|
|
1324
|
-
*/
|
|
1325
|
-
export declare const subtract: (arg1: number, arg2: number) => number;
|
|
1326
|
-
|
|
1327
|
-
/**
|
|
1328
|
-
* 判断是否支持canvas
|
|
1329
|
-
* @returns {boolean}
|
|
1330
|
-
*/
|
|
1331
|
-
export declare function supportCanvas(): boolean;
|
|
1332
|
-
|
|
1333
|
-
/**
|
|
1334
|
-
* 节流函数
|
|
1335
|
-
* 节流就是节约流量,将连续触发的事件稀释成预设评率。 比如每间隔1秒执行一次函数,无论这期间触发多少次事件。
|
|
1336
|
-
* 这有点像公交车,无论在站点等车的人多不多,公交车只会按时来一班,不会来一个人就来一辆公交车。
|
|
1337
|
-
* @param {F} func
|
|
1338
|
-
* @param {number} wait
|
|
1339
|
-
* @param {boolean} immediate
|
|
1340
|
-
* @returns {ThrottleFunc<F>}
|
|
1341
|
-
*/
|
|
1342
|
-
export declare const throttle: <F extends AnyFunc>(func: F, wait: number, immediate?: boolean) => ThrottleFunc<F>;
|
|
1343
|
-
|
|
1344
|
-
export declare interface ThrottleFunc<F extends AnyFunc> {
|
|
1345
|
-
(...args: Parameters<F>): void;
|
|
1346
|
-
cancel: () => void;
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
export declare const tooltipEvent: {
|
|
1350
|
-
handleMouseEnter: typeof handleMouseEnter;
|
|
1351
|
-
handleMouseLeave: typeof handleMouseLeave;
|
|
1352
|
-
};
|
|
1353
|
-
|
|
1354
|
-
/**
|
|
1355
|
-
* 判断任意值的数据类型,检查非对象时不如typeof、instanceof的性能高
|
|
1356
|
-
*
|
|
1357
|
-
* 当检查类对象时是不可靠的,对象可以通过定义 Symbol.toStringTag 属性来更改检查结果
|
|
1358
|
-
*
|
|
1359
|
-
* 详见:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
|
|
1360
|
-
* @param {unknown} any
|
|
1361
|
-
* @returns
|
|
1362
|
-
*/
|
|
1363
|
-
export declare function typeIs(any: unknown): 'Null' | 'Undefined' | 'Symbol' | 'Boolean' | 'Number' | 'String' | 'Function' | 'Date' | 'RegExp' | 'Map' | 'Set' | 'ArrayBuffer' | 'Object' | 'Array' | 'Error' | 'BigInt' | 'Promise' | 'AsyncFunction' | string;
|
|
1364
|
-
|
|
1365
|
-
/**
|
|
1366
|
-
* 增强型 Unicode/HTML/UTF-8 编码解码工具
|
|
1367
|
-
*/
|
|
1368
|
-
export declare class UnicodeToolkit {
|
|
1369
|
-
private static readonly ENTITY_MAP;
|
|
1370
|
-
private static readonly NAMED_ENTITIES;
|
|
1371
|
-
/**
|
|
1372
|
-
* 编码函数
|
|
1373
|
-
* @param str 原始字符串
|
|
1374
|
-
* @param mode 'unicode' (\uXXXX) | 'html' ({) | 'entities' (命名实体)
|
|
1375
|
-
* @param encodeAll 是否编码 ASCII 可见字符 (默认 false,仅编码非 ASCII 和特殊字符)
|
|
1376
|
-
* * @example
|
|
1377
|
-
* // Unicode 编码 (默认仅编码非 ASCII)
|
|
1378
|
-
* UnicodeToolkit.encode('Hi 你好 😀')
|
|
1379
|
-
* // => 'Hi \\u4F60\\u597D \\u{1F600}'
|
|
1380
|
-
* * @example
|
|
1381
|
-
* // 全部Unicode 编码
|
|
1382
|
-
* UnicodeToolkit.encode('Hi 你好 😀','unicode', true)
|
|
1383
|
-
* // => '\\u0048\\u0069\\u0020\\u4F60\\u597D\\u0020\\u{1F600}'
|
|
1384
|
-
* * @example
|
|
1385
|
-
* // HTML 实体编码
|
|
1386
|
-
* UnicodeToolkit.encode('<script>', 'html',true)
|
|
1387
|
-
* // => '<script>&'
|
|
1388
|
-
*/
|
|
1389
|
-
static encode(str: string, mode?: 'unicode' | 'html', encodeAll?: boolean): string;
|
|
1390
|
-
/**
|
|
1391
|
-
* 综合解码 (支持 \uXXXX, \u{XXXX}, HTML 实体, 十六进制实体)
|
|
1392
|
-
* @param normalizeSpace 是否将 \u00A0 ( ) 转换为普通空格 \u0020
|
|
1393
|
-
* * @example
|
|
1394
|
-
* // 解码 Unicode 和 Emoji
|
|
1395
|
-
* UnicodeToolkit.decode('\\u4F60\\u597D\\u{1F680}')
|
|
1396
|
-
* // => '你好🚀'
|
|
1397
|
-
* * @example
|
|
1398
|
-
* // 解码 HTML 实体 (支持十进制、十六进制和命名实体)
|
|
1399
|
-
* UnicodeToolkit.decode('Price: £10 & ©')
|
|
1400
|
-
* // => 'Price: £10 & ©'
|
|
1401
|
-
* * @example
|
|
1402
|
-
* // 空格归一化 (将 转为标准空格)
|
|
1403
|
-
* UnicodeToolkit.decode('A B', true)
|
|
1404
|
-
* // => 'A B' (charCodeAt 为 32 而不是 160)
|
|
1405
|
-
*/
|
|
1406
|
-
static decode(str: string, normalizeSpace?: boolean): string;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
export declare const UNIQUE_NUMBER_SAFE_LENGTH = 18;
|
|
1410
|
-
|
|
1411
|
-
/**
|
|
1412
|
-
* 生成唯一不重复数值
|
|
1413
|
-
* @param {number} length
|
|
1414
|
-
* @returns {string}
|
|
1415
|
-
*/
|
|
1416
|
-
export declare const uniqueNumber: (length?: number) => string;
|
|
1417
|
-
|
|
1418
|
-
export declare interface UniqueString {
|
|
1419
|
-
(length: number, pool: string): string;
|
|
1420
|
-
(length: number): string;
|
|
1421
|
-
(pool: string): string;
|
|
1422
|
-
(): string;
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
/**
|
|
1426
|
-
* 生成唯一不重复字符串
|
|
1427
|
-
* @param {number | string} length
|
|
1428
|
-
* @param {string} pool
|
|
1429
|
-
* @returns {string}
|
|
1430
|
-
*/
|
|
1431
|
-
export declare const uniqueString: UniqueString;
|
|
1432
|
-
|
|
1433
|
-
/**
|
|
1434
|
-
* 去除字符串中重复字符
|
|
1435
|
-
* @param {string} str
|
|
1436
|
-
* @returns string
|
|
1437
|
-
* @example
|
|
1438
|
-
*
|
|
1439
|
-
* uniqueSymbol('1a1bac');
|
|
1440
|
-
* // => '1abc'
|
|
1441
|
-
*/
|
|
1442
|
-
export declare function uniqueSymbol(str: string): string;
|
|
1443
|
-
|
|
1444
|
-
export declare interface Url {
|
|
1445
|
-
protocol: string;
|
|
1446
|
-
auth: string;
|
|
1447
|
-
username: string;
|
|
1448
|
-
password: string;
|
|
1449
|
-
host: string;
|
|
1450
|
-
port: string;
|
|
1451
|
-
hostname: string;
|
|
1452
|
-
hash: string;
|
|
1453
|
-
search: string;
|
|
1454
|
-
searchParams: Params;
|
|
1455
|
-
query: string;
|
|
1456
|
-
pathname: string;
|
|
1457
|
-
path: string;
|
|
1458
|
-
href: string;
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
export declare const URL_REGEX: RegExp;
|
|
1462
|
-
|
|
1463
|
-
/**
|
|
1464
|
-
* 删除 url 查询参数
|
|
1465
|
-
* @param {string} url
|
|
1466
|
-
* @param {string[]} removeKeys
|
|
1467
|
-
* @returns {string}
|
|
1468
|
-
*/
|
|
1469
|
-
export declare const urlDelParams: (url: string, removeKeys: string[]) => string;
|
|
1470
|
-
|
|
1471
|
-
/**
|
|
1472
|
-
* url 解析
|
|
1473
|
-
* @param {string} url
|
|
1474
|
-
* @param {boolean} isModernApi 使用现代API:URL, 默认true (对无效url解析会抛错), 否则使用a标签来解析(兼容性更强)
|
|
1475
|
-
* @returns {Url}
|
|
1476
|
-
*/
|
|
1477
|
-
export declare const urlParse: (url: string, isModernApi?: boolean) => Url;
|
|
1478
|
-
|
|
1479
|
-
/**
|
|
1480
|
-
* 设置 url 查询参数
|
|
1481
|
-
* @param {string} url
|
|
1482
|
-
* @param {AnyObject} setter
|
|
1483
|
-
* @returns {string}
|
|
1484
|
-
*/
|
|
1485
|
-
export declare const urlSetParams: (url: string, setter: AnyObject) => string;
|
|
1486
|
-
|
|
1487
|
-
/**
|
|
1488
|
-
* url 字符化,url 对象里的 searchParams 会覆盖 url 原有的查询参数
|
|
1489
|
-
* @param {Url} url
|
|
1490
|
-
* @returns {string}
|
|
1491
|
-
*/
|
|
1492
|
-
export declare const urlStringify: (url: Url) => string;
|
|
1493
|
-
|
|
1494
|
-
/**
|
|
1495
|
-
* 等待一段时间
|
|
1496
|
-
* @param {number} timeout 等待时间,单位毫秒
|
|
1497
|
-
* @returns {Promise<void>}
|
|
1498
|
-
*/
|
|
1499
|
-
export declare function wait(timeout?: number): Promise<void>;
|
|
1500
|
-
|
|
1501
|
-
/**
|
|
1502
|
-
* Base64解码为原始字符串,平替浏览器的atob, 不包含中文的处理(适用于任何环境,包括小程序)
|
|
1503
|
-
* @param {string} string
|
|
1504
|
-
* @returns {string}
|
|
1505
|
-
*/
|
|
1506
|
-
export declare function weAtob(string: string): string;
|
|
1507
|
-
|
|
1508
|
-
/**
|
|
1509
|
-
* 字符串编码成Base64, 平替浏览器的btoa, 不包含中文的处理 (适用于任何环境,包括小程序)
|
|
1510
|
-
* @param {string} string
|
|
1511
|
-
* @returns {string}
|
|
1512
|
-
*/
|
|
1513
|
-
export declare function weBtoa(string: string): string;
|
|
1514
|
-
|
|
1515
|
-
export { }
|