minutool 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.
- package/README.md +233 -0
- package/dist/index.d.ts +1178 -0
- package/dist/minutool.js +1181 -0
- package/dist/minutool.umd.cjs +4 -0
- package/package.json +51 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数组分块
|
|
3
|
+
* @param {Array} list 数据
|
|
4
|
+
* @param {Number} size 每块大小
|
|
5
|
+
* @return {Array[]}
|
|
6
|
+
*/
|
|
7
|
+
export declare const arrayChunk: <T = any>(list: T[], size: number) => T[][];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* array_column
|
|
11
|
+
* @param arr
|
|
12
|
+
* @param col_name
|
|
13
|
+
* @returns {Array}
|
|
14
|
+
*/
|
|
15
|
+
export declare const arrayColumn: <T = any>(arr: T[], col_name: keyof T) => any[];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 数组去重
|
|
19
|
+
* @param {Array} arr
|
|
20
|
+
* @returns {*}
|
|
21
|
+
*/
|
|
22
|
+
export declare const arrayDistinct: <T = any>(arr: T[]) => T[];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* array group
|
|
26
|
+
* @param arr
|
|
27
|
+
* @param by_key
|
|
28
|
+
* @param limit limit one child
|
|
29
|
+
* @returns {*}
|
|
30
|
+
*/
|
|
31
|
+
export declare const arrayGroup: <T extends Record<string, any>>(arr: T[], by_key: keyof T, limit?: boolean) => Record<string, T[]> | Record<string, T>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param arr
|
|
35
|
+
* @param val
|
|
36
|
+
* @return {string|null}
|
|
37
|
+
*/
|
|
38
|
+
export declare const arrayIndex: <T = any>(arr: T[], val: T) => string | null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 按照对象 KEY 排序
|
|
42
|
+
* @param {Object} obj
|
|
43
|
+
* @return {{}}
|
|
44
|
+
*/
|
|
45
|
+
export declare const arraySortByKey: <T extends Record<string, any>>(obj: T) => T;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 从数组末尾开始移除值为 falsy 的元素,直到遇到第一个 truthy 元素
|
|
49
|
+
* @param arr 要处理的数组
|
|
50
|
+
* @returns 处理后的数组
|
|
51
|
+
*/
|
|
52
|
+
export declare const arrayTrimTail: (arr: any[]) => any[];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* base64 解码
|
|
56
|
+
* @param {string} text
|
|
57
|
+
* @returns {string}
|
|
58
|
+
*/
|
|
59
|
+
export declare const base64Decode: (text: string) => string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* text 转 base64
|
|
63
|
+
* @param {String} text
|
|
64
|
+
* @return {string}
|
|
65
|
+
* @constructor
|
|
66
|
+
*/
|
|
67
|
+
export declare const Base64Encode: (text: string) => string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* URL 安全模式进行 base64 编码
|
|
71
|
+
* @param {String} text
|
|
72
|
+
* @return {string}
|
|
73
|
+
*/
|
|
74
|
+
export declare const base64UrlSafeEncode: (text: string) => string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 检测指定值是否在指定区间内
|
|
78
|
+
* @param {Number} val
|
|
79
|
+
* @param {Number} min
|
|
80
|
+
* @param {Number} max
|
|
81
|
+
* @param {Boolean} includeEqual 是否包含等于判断
|
|
82
|
+
* @returns {boolean}
|
|
83
|
+
*/
|
|
84
|
+
export declare const between: (val: number, min: number, max: number, includeEqual?: boolean) => boolean;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 转换blob数据到base64
|
|
88
|
+
* @param {Blob} blob
|
|
89
|
+
* @returns {Promise<unknown>}
|
|
90
|
+
*/
|
|
91
|
+
export declare const blobToBase64: (blob: Blob) => Promise<unknown>;
|
|
92
|
+
|
|
93
|
+
export declare const blobToDataUri: (blob: Blob) => Promise<string>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 块元素
|
|
97
|
+
* 用大写定义,方便直接匹配 node.tagName
|
|
98
|
+
* @type {string[]}
|
|
99
|
+
*/
|
|
100
|
+
export declare const BLOCK_TAGS: string[];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 构建 HTML Input:hidden 标签
|
|
104
|
+
* @param {Object} maps {key:value}
|
|
105
|
+
* @return {string}
|
|
106
|
+
*/
|
|
107
|
+
export declare const buildHtmlHidden: (maps: Record<string, any>) => string;
|
|
108
|
+
|
|
109
|
+
export declare const buildStyleVars: (vars: Record<string, number | string | undefined>) => Record<string, string>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 驼峰命名转换
|
|
113
|
+
* @param str - 输入字符串
|
|
114
|
+
* @returns 驼峰命名的字符串
|
|
115
|
+
* @example
|
|
116
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
117
|
+
* camelCase('hello_world') // 'helloWorld'
|
|
118
|
+
*/
|
|
119
|
+
export declare function camelCase(str: string): string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 首字母大写
|
|
123
|
+
* @param str - 输入字符串
|
|
124
|
+
* @returns 首字母大写的字符串
|
|
125
|
+
* @example
|
|
126
|
+
* capitalize('hello') // 'Hello'
|
|
127
|
+
*/
|
|
128
|
+
export declare function capitalize(str: string): string;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 清理对象中的 null 值
|
|
132
|
+
*/
|
|
133
|
+
export declare const cleanNull: (obj: any, recursive?: boolean) => any;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 计时(该方法采用timeout方式,不够精准
|
|
137
|
+
* @param {Number} timeout
|
|
138
|
+
* @param {Function} tickFunc
|
|
139
|
+
* @param {Function} onFinish
|
|
140
|
+
*/
|
|
141
|
+
export declare const countDown: (timeout: number, tickFunc?: (timeout: number) => void, onFinish?: () => void) => void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 创建HTML节点
|
|
145
|
+
* @param {String} html
|
|
146
|
+
* @param {HTMLElement|null} parentNode 父级节点
|
|
147
|
+
* @returns {HTMLElement|HTMLElement[]}
|
|
148
|
+
*/
|
|
149
|
+
export declare const createDomByHtml: (html: string, parentNode?: HTMLElement | null) => Node | Node[];
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* CSS 选择器转义
|
|
153
|
+
* @param {String} str
|
|
154
|
+
* @returns {String}
|
|
155
|
+
*/
|
|
156
|
+
export declare const cssSelectorEscape: (str: string) => string;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 中英文字符串截取(中文按照2个字符长度计算)
|
|
160
|
+
* @param str
|
|
161
|
+
* @param len
|
|
162
|
+
* @param eclipse_text
|
|
163
|
+
* @returns {*}
|
|
164
|
+
*/
|
|
165
|
+
export declare const cutString: (str: string, len: number, eclipse_text?: string) => string;
|
|
166
|
+
|
|
167
|
+
export declare const DATE_NOW: number;
|
|
168
|
+
|
|
169
|
+
export declare const DAY_FRIDAY = 5;
|
|
170
|
+
|
|
171
|
+
export declare const DAY_MONDAY = 1;
|
|
172
|
+
|
|
173
|
+
export declare const DAY_SATURDAY = 6;
|
|
174
|
+
|
|
175
|
+
export declare const DAY_SUNDAY = 0;
|
|
176
|
+
|
|
177
|
+
export declare const DAY_THURSDAY = 4;
|
|
178
|
+
|
|
179
|
+
export declare const DAY_TUESDAY = 2;
|
|
180
|
+
|
|
181
|
+
export declare const DAY_WEDNESDAY = 3;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 在事件被触发n秒后再执行回调,如果在这n秒内又被触发,则重新计时。
|
|
185
|
+
* @param {Function} fn
|
|
186
|
+
* @param {Number} intervalMiSec
|
|
187
|
+
* @return {(function(): void)|*}
|
|
188
|
+
*/
|
|
189
|
+
export declare const debounce: (fn: Function, intervalMiSec: number) => Function;
|
|
190
|
+
|
|
191
|
+
export declare const decodeHTMLEntities: (str: string) => string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 深拷贝对象
|
|
195
|
+
* @param obj - 要拷贝的对象
|
|
196
|
+
* @returns 拷贝后的新对象
|
|
197
|
+
* @example
|
|
198
|
+
* deepClone({ a: 1, b: { c: 2 } })
|
|
199
|
+
*/
|
|
200
|
+
export declare function deepClone<T>(obj: T): T;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 删除cookie
|
|
204
|
+
* @param name
|
|
205
|
+
*/
|
|
206
|
+
export declare const deleteCookie: (name: string) => void;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 检测数值最大精度
|
|
210
|
+
* @param {...any} numbers 待检测数值
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
export declare const detectedPrecision: (...numbers: number[]) => number;
|
|
214
|
+
|
|
215
|
+
export declare const detectLanguage: (supportedLngs: string[]) => any;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 计算数字位数
|
|
219
|
+
* @param {Number} n
|
|
220
|
+
* @returns
|
|
221
|
+
*/
|
|
222
|
+
export declare const digitCount: (n: number) => number;
|
|
223
|
+
|
|
224
|
+
declare interface Dimension {
|
|
225
|
+
left: number;
|
|
226
|
+
top: number;
|
|
227
|
+
width: number;
|
|
228
|
+
height: number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 禁用元素(禁止交互,设置disabled)
|
|
233
|
+
* @param {String|Node} el
|
|
234
|
+
* @param {String} disabledClass
|
|
235
|
+
*/
|
|
236
|
+
export declare const disabled: (el: HTMLElement | string, disabledClass?: string) => void;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 下载文件
|
|
240
|
+
* @param {String} uri
|
|
241
|
+
* @param {String} fileName
|
|
242
|
+
*/
|
|
243
|
+
export declare const downloadFile: (uri: string, fileName: string) => void;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 启用元素(允许交互,移除disabled)
|
|
247
|
+
* @param {String|Node} el
|
|
248
|
+
* @param {String} disabledClass
|
|
249
|
+
*/
|
|
250
|
+
export declare const enabled: (el: HTMLElement | string, disabledClass?: string) => void;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 进入全屏模式
|
|
254
|
+
* @param {HTMLElement} element
|
|
255
|
+
*/
|
|
256
|
+
export declare const enterFullScreen: (element: any) => Promise<void>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* HTML实例转字符串
|
|
260
|
+
* @param {string} entity
|
|
261
|
+
* @returns {string}
|
|
262
|
+
*/
|
|
263
|
+
export declare const entityToString: (entity: string) => string;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 转义HTML到属性值
|
|
267
|
+
* @param {String} s
|
|
268
|
+
* @param preserveCR
|
|
269
|
+
* @returns {string}
|
|
270
|
+
*/
|
|
271
|
+
export declare const escapeAttr: (s: string, preserveCR?: string) => string;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 转义HTML
|
|
275
|
+
* @param {string} str
|
|
276
|
+
* @param {Number} tabSize tab宽度,如果设置为0,表示去除tab
|
|
277
|
+
* @param {Boolean} allowLineBreaker 是否允许换行
|
|
278
|
+
* @returns {string}
|
|
279
|
+
*/
|
|
280
|
+
export declare const escapeHtml: (str: string, tabSize?: number, allowLineBreaker?: boolean) => string;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 退出全屏
|
|
284
|
+
* @returns {Promise<void>}
|
|
285
|
+
*/
|
|
286
|
+
export declare const exitFullScreen: () => Promise<void>;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* 混合ES6模板字符串
|
|
290
|
+
* @example extract("hello ${user_name}", {user_name:"Jack"});
|
|
291
|
+
* @param {String} es_template 模板
|
|
292
|
+
* @param {Object} params 数据对象
|
|
293
|
+
* @return {String}
|
|
294
|
+
*/
|
|
295
|
+
export declare const extract: (es_template: string, params: Record<string, any>) => string;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 将文件转换为 Base64 data URL
|
|
299
|
+
* 支持 File/Blob 对象,或字符串 URL(http(s)/相对/blob:)
|
|
300
|
+
* @param {File|Blob|String} file
|
|
301
|
+
* @returns {Promise<String|null>} 返回 data URL 字符串,失败返回 null
|
|
302
|
+
*/
|
|
303
|
+
export declare const fileToBase64DataUri: (file: File | Blob | string) => Promise<string | null>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 通过选择器查找子节点(强制添加 :scope来约束必须是子节点)
|
|
307
|
+
* @param {String} selector
|
|
308
|
+
* @param {Node} parent
|
|
309
|
+
* @return {Node[]}
|
|
310
|
+
*/
|
|
311
|
+
export declare const findAll: (selector: string | HTMLElement | HTMLElement[] | NodeList | HTMLCollection, parent?: Document | HTMLElement) => HTMLElement[];
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* @param {String|Object} selector 选择器,如果是Object,则直接返回Object
|
|
315
|
+
* @param {Node} parent
|
|
316
|
+
* @return {Node}
|
|
317
|
+
*/
|
|
318
|
+
export declare const findOne: (selector: string | HTMLElement, parent?: Document | HTMLElement) => HTMLElement;
|
|
319
|
+
|
|
320
|
+
export declare const fixBaseUrl: (url: string, baseUrl: string) => string;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* 格式化日期(以PHP方式格式化)
|
|
324
|
+
* @param {String} format
|
|
325
|
+
* @param {Object,Number,String} date 日期,可以是日期对象、毫秒数或者日期字符串,缺省为今天
|
|
326
|
+
* @return {String}
|
|
327
|
+
*/
|
|
328
|
+
export declare const formatDate: (format: string, date?: Date | number | string | null) => string;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 获取元素的位置(相对于视口)
|
|
332
|
+
* @param {HTMLElement} el
|
|
333
|
+
* @returns
|
|
334
|
+
*/
|
|
335
|
+
export declare const getBoundingClientRect: (el: HTMLElement, autoFixInvisible?: boolean) => RectObject;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 获取cookie
|
|
339
|
+
* @param {String} name
|
|
340
|
+
* @returns {string|null}
|
|
341
|
+
*/
|
|
342
|
+
export declare const getCookie: (name: string) => string | null;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* 获取对象宽、高
|
|
346
|
+
* 通过设置 visibility 方式进行获取
|
|
347
|
+
* @param {HTMLElement} dom
|
|
348
|
+
* @return {{width: number, height: number}}
|
|
349
|
+
*/
|
|
350
|
+
export declare const getDomDimension: (dom: HTMLElement) => {
|
|
351
|
+
width: number;
|
|
352
|
+
height: number;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* get node xpath
|
|
357
|
+
* @param el
|
|
358
|
+
* @return {String}
|
|
359
|
+
*/
|
|
360
|
+
export declare const getNodeXPath: (el: HTMLElement | null) => string | null;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* 获取u8字符串长度(一个中文字按照3个字数计算)
|
|
364
|
+
* @param str
|
|
365
|
+
* @returns {number}
|
|
366
|
+
*/
|
|
367
|
+
export declare const getUTF8StrLen: (str: string) => number;
|
|
368
|
+
|
|
369
|
+
/** 黄金分割比 0.618 **/
|
|
370
|
+
export declare const GOLDEN_RATIO: number;
|
|
371
|
+
|
|
372
|
+
export declare const guid: (prefix?: string) => string;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 隐藏节点(通过设置display:none方式)
|
|
376
|
+
* @param {Node|String} dom
|
|
377
|
+
*/
|
|
378
|
+
export declare const hide: (dom: HTMLElement | string) => void;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 高亮文本
|
|
382
|
+
* @param {String} text 文本
|
|
383
|
+
* @param {String} kw 关键字
|
|
384
|
+
* @param {String} replaceTpl 替换模板
|
|
385
|
+
* @returns {void|string|*}
|
|
386
|
+
*/
|
|
387
|
+
export declare const highlightText: (text: string, kw: string, replaceTpl?: string) => string;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Convert html to plain text
|
|
391
|
+
* @param {String} html
|
|
392
|
+
* @returns {string}
|
|
393
|
+
*/
|
|
394
|
+
export declare const html2Text: (html: string) => string;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* 通过 Image 获取base64数据
|
|
398
|
+
* @param img
|
|
399
|
+
* @returns {string|string|*|string|null}
|
|
400
|
+
*/
|
|
401
|
+
export declare const imgToBase64: (img: HTMLImageElement) => string | null;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* 在头部插入样式
|
|
405
|
+
* @param {String} styleSheetStr 样式代码
|
|
406
|
+
* @param {String} id 样式ID,如果提供ID,将会检测是否已经插入,可以避免重复插入
|
|
407
|
+
* @param {Document} doc 文档上下文
|
|
408
|
+
* @return {HTMLStyleElement}
|
|
409
|
+
*/
|
|
410
|
+
export declare const insertStyleSheet: (styleSheetStr: string, id?: string, doc?: Document) => HTMLStyleElement | null;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* 判断对象是否为空
|
|
414
|
+
* @param obj - 要判断的对象
|
|
415
|
+
* @returns 是否为空对象
|
|
416
|
+
* @example
|
|
417
|
+
* isEmptyObject({}) // true
|
|
418
|
+
* isEmptyObject({ a: 1 }) // false
|
|
419
|
+
*/
|
|
420
|
+
export declare function isEmptyObject(obj: object): boolean;
|
|
421
|
+
|
|
422
|
+
export declare const isFocusable: (el: HTMLElement) => boolean;
|
|
423
|
+
|
|
424
|
+
export declare const isFunction: (value: any) => boolean;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 检测是否正在全屏
|
|
428
|
+
* @returns {boolean}
|
|
429
|
+
*/
|
|
430
|
+
export declare const isInFullScreen: () => boolean;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* 判断字符串是否符合 JSON 标准
|
|
434
|
+
* @param {String} json
|
|
435
|
+
* @returns {boolean}
|
|
436
|
+
*/
|
|
437
|
+
export declare const isJSON: (json: string) => boolean;
|
|
438
|
+
|
|
439
|
+
export declare const isJson: (json: string) => boolean;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* 检测目标是否为 Object
|
|
443
|
+
* @param {*} item
|
|
444
|
+
* @returns {boolean}
|
|
445
|
+
*/
|
|
446
|
+
export declare const isObject: (item: any) => boolean;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* 检测对象是否为Promise对象
|
|
450
|
+
* @param {*} obj
|
|
451
|
+
* @returns {boolean}
|
|
452
|
+
*/
|
|
453
|
+
export declare const isPromise: (obj: any) => boolean;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* 检测是否为 URL(不包含 blob: data: file: 等协议)
|
|
457
|
+
*/
|
|
458
|
+
export declare const isUrl: (str: string) => boolean;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* 短横线命名转换
|
|
462
|
+
* @param str - 输入字符串
|
|
463
|
+
* @returns 短横线命名的字符串
|
|
464
|
+
* @example
|
|
465
|
+
* kebabCase('helloWorld') // 'hello-world'
|
|
466
|
+
* kebabCase('HelloWorld') // 'hello-world'
|
|
467
|
+
*/
|
|
468
|
+
export declare function kebabCase(str: string): string;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* 保持对象尽量在容器内部,优先保证上边、左边显示
|
|
472
|
+
* @param {Object} objDim
|
|
473
|
+
* @param {Number} objDim.left
|
|
474
|
+
* @param {Number} objDim.top
|
|
475
|
+
* @param {Number} objDim.width
|
|
476
|
+
* @param {Number} objDim.height
|
|
477
|
+
* @param {Object} ctnDim
|
|
478
|
+
* @param {Number} ctnDim.left
|
|
479
|
+
* @param {Number} ctnDim.top
|
|
480
|
+
* @param {Number} ctnDim.width
|
|
481
|
+
* @param {Number} ctnDim.height
|
|
482
|
+
* {Array} dimension [dimension.left, dimension.top]
|
|
483
|
+
*/
|
|
484
|
+
export declare const keepRectInContainer: (objDim: Dimension, ctnDim?: Dimension) => {
|
|
485
|
+
left: number;
|
|
486
|
+
top: number;
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* 挂载css文件
|
|
491
|
+
* @param {String} file
|
|
492
|
+
* @param {Boolean} forceReload 是否强制重新挂载,缺省不重复挂载
|
|
493
|
+
*/
|
|
494
|
+
export declare const loadCss: (file: string, forceReload?: boolean) => Promise<void>;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* 加载script脚本
|
|
498
|
+
* @param {String} src 脚本地址
|
|
499
|
+
* @param {Boolean} forceReload 是否强制重新加载,缺省为去重加载
|
|
500
|
+
* @return {Promise}
|
|
501
|
+
*/
|
|
502
|
+
export declare const loadScript: (src: string, forceReload?: boolean) => Promise<void>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* 绑定元素,禁止交互
|
|
506
|
+
* @param {Node} el
|
|
507
|
+
* @param {Function} payload 处理函数,参数为 reset
|
|
508
|
+
*/
|
|
509
|
+
export declare const lockElementInteraction: (el: HTMLElement | string, payload: (reset: () => void) => void) => void;
|
|
510
|
+
|
|
511
|
+
export declare const md5: (string: string, key?: string, raw?: boolean) => string;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* 缺省二进制文件MIME
|
|
515
|
+
* @see https://datatracker.ietf.org/doc/html/rfc2046
|
|
516
|
+
* @type {String}
|
|
517
|
+
*/
|
|
518
|
+
export declare const MIME_BINARY_DEFAULT = "application/octet-stream";
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* MIME常见扩展名映射表
|
|
522
|
+
* @type {Object}
|
|
523
|
+
*/
|
|
524
|
+
export declare const MIME_EXTENSION_MAP: {
|
|
525
|
+
"323": string;
|
|
526
|
+
accdb: string;
|
|
527
|
+
accde: string;
|
|
528
|
+
accdt: string;
|
|
529
|
+
acx: string;
|
|
530
|
+
ai: string;
|
|
531
|
+
aif: string;
|
|
532
|
+
aifc: string;
|
|
533
|
+
aiff: string;
|
|
534
|
+
application: string;
|
|
535
|
+
art: string;
|
|
536
|
+
asf: string;
|
|
537
|
+
asm: string;
|
|
538
|
+
asr: string;
|
|
539
|
+
asx: string;
|
|
540
|
+
atom: string;
|
|
541
|
+
au: string;
|
|
542
|
+
avi: string;
|
|
543
|
+
axs: string;
|
|
544
|
+
bas: string;
|
|
545
|
+
bcpio: string;
|
|
546
|
+
bmp: string;
|
|
547
|
+
c: string;
|
|
548
|
+
calx: string;
|
|
549
|
+
cat: string;
|
|
550
|
+
cdf: string;
|
|
551
|
+
class: string;
|
|
552
|
+
clp: string;
|
|
553
|
+
cmx: string;
|
|
554
|
+
cnf: string;
|
|
555
|
+
cod: string;
|
|
556
|
+
cpio: string;
|
|
557
|
+
cpp: string;
|
|
558
|
+
crd: string;
|
|
559
|
+
crl: string;
|
|
560
|
+
crt: string;
|
|
561
|
+
csh: string;
|
|
562
|
+
css: string;
|
|
563
|
+
dcr: string;
|
|
564
|
+
der: string;
|
|
565
|
+
dib: string;
|
|
566
|
+
dir: string;
|
|
567
|
+
disco: string;
|
|
568
|
+
dll: string;
|
|
569
|
+
"dll.config": string;
|
|
570
|
+
dlm: string;
|
|
571
|
+
doc: string;
|
|
572
|
+
docm: string;
|
|
573
|
+
docx: string;
|
|
574
|
+
dot: string;
|
|
575
|
+
dotm: string;
|
|
576
|
+
dotx: string;
|
|
577
|
+
dtd: string;
|
|
578
|
+
dvi: string;
|
|
579
|
+
dwf: string;
|
|
580
|
+
dxr: string;
|
|
581
|
+
eml: string;
|
|
582
|
+
eps: string;
|
|
583
|
+
etx: string;
|
|
584
|
+
evy: string;
|
|
585
|
+
"exe.config": string;
|
|
586
|
+
fdf: string;
|
|
587
|
+
fif: string;
|
|
588
|
+
flr: string;
|
|
589
|
+
flv: string;
|
|
590
|
+
gif: string;
|
|
591
|
+
gtar: string;
|
|
592
|
+
gz: string;
|
|
593
|
+
h: string;
|
|
594
|
+
hdf: string;
|
|
595
|
+
hdml: string;
|
|
596
|
+
hhc: string;
|
|
597
|
+
hlp: string;
|
|
598
|
+
hqx: string;
|
|
599
|
+
hta: string;
|
|
600
|
+
htc: string;
|
|
601
|
+
htm: string;
|
|
602
|
+
html: string;
|
|
603
|
+
htt: string;
|
|
604
|
+
hxt: string;
|
|
605
|
+
ico: string;
|
|
606
|
+
ief: string;
|
|
607
|
+
iii: string;
|
|
608
|
+
ins: string;
|
|
609
|
+
isp: string;
|
|
610
|
+
IVF: string;
|
|
611
|
+
jar: string;
|
|
612
|
+
jck: string;
|
|
613
|
+
jcz: string;
|
|
614
|
+
jfif: string;
|
|
615
|
+
jpe: string;
|
|
616
|
+
jpeg: string;
|
|
617
|
+
jpg: string;
|
|
618
|
+
js: string;
|
|
619
|
+
jsx: string;
|
|
620
|
+
latex: string;
|
|
621
|
+
lit: string;
|
|
622
|
+
lsf: string;
|
|
623
|
+
lsx: string;
|
|
624
|
+
m13: string;
|
|
625
|
+
m14: string;
|
|
626
|
+
m1v: string;
|
|
627
|
+
m3u: string;
|
|
628
|
+
man: string;
|
|
629
|
+
manifest: string;
|
|
630
|
+
map: string;
|
|
631
|
+
mdb: string;
|
|
632
|
+
me: string;
|
|
633
|
+
mht: string;
|
|
634
|
+
mhtml: string;
|
|
635
|
+
mid: string;
|
|
636
|
+
midi: string;
|
|
637
|
+
mmf: string;
|
|
638
|
+
mno: string;
|
|
639
|
+
mny: string;
|
|
640
|
+
mov: string;
|
|
641
|
+
movie: string;
|
|
642
|
+
mp2: string;
|
|
643
|
+
mp3: string;
|
|
644
|
+
mpa: string;
|
|
645
|
+
mpe: string;
|
|
646
|
+
mpeg: string;
|
|
647
|
+
mpg: string;
|
|
648
|
+
mpp: string;
|
|
649
|
+
mpv2: string;
|
|
650
|
+
ms: string;
|
|
651
|
+
mvb: string;
|
|
652
|
+
mvc: string;
|
|
653
|
+
nc: string;
|
|
654
|
+
nsc: string;
|
|
655
|
+
nws: string;
|
|
656
|
+
oda: string;
|
|
657
|
+
odc: string;
|
|
658
|
+
ods: string;
|
|
659
|
+
one: string;
|
|
660
|
+
onea: string;
|
|
661
|
+
onetoc: string;
|
|
662
|
+
onetoc2: string;
|
|
663
|
+
onetmp: string;
|
|
664
|
+
onepkg: string;
|
|
665
|
+
osdx: string;
|
|
666
|
+
p10: string;
|
|
667
|
+
p12: string;
|
|
668
|
+
p7b: string;
|
|
669
|
+
p7c: string;
|
|
670
|
+
p7m: string;
|
|
671
|
+
p7r: string;
|
|
672
|
+
p7s: string;
|
|
673
|
+
pbm: string;
|
|
674
|
+
pdf: string;
|
|
675
|
+
pfx: string;
|
|
676
|
+
pgm: string;
|
|
677
|
+
pko: string;
|
|
678
|
+
pma: string;
|
|
679
|
+
pmc: string;
|
|
680
|
+
pml: string;
|
|
681
|
+
pmr: string;
|
|
682
|
+
pmw: string;
|
|
683
|
+
png: string;
|
|
684
|
+
pnm: string;
|
|
685
|
+
pnz: string;
|
|
686
|
+
pot: string;
|
|
687
|
+
potm: string;
|
|
688
|
+
potx: string;
|
|
689
|
+
ppam: string;
|
|
690
|
+
ppm: string;
|
|
691
|
+
pps: string;
|
|
692
|
+
ppsm: string;
|
|
693
|
+
ppsx: string;
|
|
694
|
+
ppt: string;
|
|
695
|
+
pptm: string;
|
|
696
|
+
pptx: string;
|
|
697
|
+
prf: string;
|
|
698
|
+
ps: string;
|
|
699
|
+
pub: string;
|
|
700
|
+
qt: string;
|
|
701
|
+
qtl: string;
|
|
702
|
+
ra: string;
|
|
703
|
+
ram: string;
|
|
704
|
+
ras: string;
|
|
705
|
+
rf: string;
|
|
706
|
+
rgb: string;
|
|
707
|
+
rm: string;
|
|
708
|
+
rmi: string;
|
|
709
|
+
roff: string;
|
|
710
|
+
rpm: string;
|
|
711
|
+
rtf: string;
|
|
712
|
+
rtx: string;
|
|
713
|
+
scd: string;
|
|
714
|
+
sct: string;
|
|
715
|
+
setpay: string;
|
|
716
|
+
setreg: string;
|
|
717
|
+
sgml: string;
|
|
718
|
+
sh: string;
|
|
719
|
+
shar: string;
|
|
720
|
+
sit: string;
|
|
721
|
+
sldm: string;
|
|
722
|
+
sldx: string;
|
|
723
|
+
smd: string;
|
|
724
|
+
smx: string;
|
|
725
|
+
smz: string;
|
|
726
|
+
snd: string;
|
|
727
|
+
spc: string;
|
|
728
|
+
spl: string;
|
|
729
|
+
src: string;
|
|
730
|
+
ssm: string;
|
|
731
|
+
sst: string;
|
|
732
|
+
stl: string;
|
|
733
|
+
sv4cpio: string;
|
|
734
|
+
sv4crc: string;
|
|
735
|
+
svg: string;
|
|
736
|
+
swf: string;
|
|
737
|
+
t: string;
|
|
738
|
+
tar: string;
|
|
739
|
+
tcl: string;
|
|
740
|
+
tex: string;
|
|
741
|
+
texi: string;
|
|
742
|
+
texinfo: string;
|
|
743
|
+
tgz: string;
|
|
744
|
+
thmx: string;
|
|
745
|
+
tif: string;
|
|
746
|
+
tiff: string;
|
|
747
|
+
tr: string;
|
|
748
|
+
trm: string;
|
|
749
|
+
tsv: string;
|
|
750
|
+
txt: string;
|
|
751
|
+
uls: string;
|
|
752
|
+
ustar: string;
|
|
753
|
+
vbs: string;
|
|
754
|
+
vcf: string;
|
|
755
|
+
vcs: string;
|
|
756
|
+
vdx: string;
|
|
757
|
+
vml: string;
|
|
758
|
+
vsd: string;
|
|
759
|
+
vss: string;
|
|
760
|
+
vst: string;
|
|
761
|
+
vsto: string;
|
|
762
|
+
vsw: string;
|
|
763
|
+
vsx: string;
|
|
764
|
+
vtx: string;
|
|
765
|
+
wav: string;
|
|
766
|
+
wax: string;
|
|
767
|
+
wbmp: string;
|
|
768
|
+
wcm: string;
|
|
769
|
+
wdb: string;
|
|
770
|
+
wks: string;
|
|
771
|
+
wm: string;
|
|
772
|
+
wma: string;
|
|
773
|
+
wmd: string;
|
|
774
|
+
wmf: string;
|
|
775
|
+
wml: string;
|
|
776
|
+
wmlc: string;
|
|
777
|
+
wmls: string;
|
|
778
|
+
wmlsc: string;
|
|
779
|
+
wmp: string;
|
|
780
|
+
wmv: string;
|
|
781
|
+
wmx: string;
|
|
782
|
+
wmz: string;
|
|
783
|
+
wps: string;
|
|
784
|
+
wri: string;
|
|
785
|
+
wrl: string;
|
|
786
|
+
wrz: string;
|
|
787
|
+
wsdl: string;
|
|
788
|
+
wvx: string;
|
|
789
|
+
x: string;
|
|
790
|
+
xaf: string;
|
|
791
|
+
xaml: string;
|
|
792
|
+
xap: string;
|
|
793
|
+
xbap: string;
|
|
794
|
+
xbm: string;
|
|
795
|
+
xdr: string;
|
|
796
|
+
xht: string;
|
|
797
|
+
xhtml: string;
|
|
798
|
+
xla: string;
|
|
799
|
+
xlam: string;
|
|
800
|
+
xlc: string;
|
|
801
|
+
xlm: string;
|
|
802
|
+
xls: string;
|
|
803
|
+
xlsb: string;
|
|
804
|
+
xlsm: string;
|
|
805
|
+
xlsx: string;
|
|
806
|
+
xlt: string;
|
|
807
|
+
xltm: string;
|
|
808
|
+
xltx: string;
|
|
809
|
+
xlw: string;
|
|
810
|
+
xml: string;
|
|
811
|
+
xof: string;
|
|
812
|
+
xpm: string;
|
|
813
|
+
xps: string;
|
|
814
|
+
xsd: string;
|
|
815
|
+
xsf: string;
|
|
816
|
+
xsl: string;
|
|
817
|
+
xslt: string;
|
|
818
|
+
xwd: string;
|
|
819
|
+
z: string;
|
|
820
|
+
zip: string;
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* 毫米转换成像素
|
|
825
|
+
* @param {float} dimension
|
|
826
|
+
* @param {int} dpi
|
|
827
|
+
* @returns int
|
|
828
|
+
*/
|
|
829
|
+
export declare const mmToPx: (dimension: number, dpi?: number) => number;
|
|
830
|
+
|
|
831
|
+
export declare const MONTH_NAMES_CN: string[];
|
|
832
|
+
|
|
833
|
+
export declare const MONTH_NAMES_SHORT_CN: string[];
|
|
834
|
+
|
|
835
|
+
export declare const MONTH_NOW: number;
|
|
836
|
+
|
|
837
|
+
export declare const msToHMS: (ms: number) => string;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* 更低占用执行mutation监听,支持指定最小间隔时间执行回调
|
|
841
|
+
* @param {Node} dom
|
|
842
|
+
* @param {Object} option
|
|
843
|
+
* @param {Boolean} option.attributes
|
|
844
|
+
* @param {Boolean} option.subtree
|
|
845
|
+
* @param {Boolean} option.childList
|
|
846
|
+
* @param {Function} payload
|
|
847
|
+
* @param {Number} minInterval 执行回调最小间隔时间(毫秒)
|
|
848
|
+
*/
|
|
849
|
+
export declare const mutationEffective: (dom: HTMLElement, option: MutationObserverInit, payload: (obs: MutationObserver) => void, minInterval?: number) => void;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* 获取当前节点在父结点中的索引号
|
|
853
|
+
* @param node
|
|
854
|
+
* @return {number}
|
|
855
|
+
*/
|
|
856
|
+
export declare const nodeIndex: (node: HTMLElement) => number;
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* 获取对象指定路径的值
|
|
860
|
+
* @param obj - 对象
|
|
861
|
+
* @param path - 路径,例如 'a.b.c'
|
|
862
|
+
* @param defaultValue - 默认值
|
|
863
|
+
* @returns 获取到的值或默认值
|
|
864
|
+
* @example
|
|
865
|
+
* get({ a: { b: { c: 1 } } }, 'a.b.c') // 1
|
|
866
|
+
* get({ a: { b: 1 } }, 'a.b.c', 0) // 0
|
|
867
|
+
*/
|
|
868
|
+
export declare function objectGet<T = any>(obj: any, path: string, defaultValue?: T): T;
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* 对象属性名转换
|
|
872
|
+
* @param {Object} obj
|
|
873
|
+
* @param {Object} mapping
|
|
874
|
+
* @return {{}}
|
|
875
|
+
*/
|
|
876
|
+
export declare const objectKeyMapping: (obj: Record<string, any>, mapping: Record<string, string>) => Record<string, any>;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* 合并对象
|
|
880
|
+
* @param target - 目标对象
|
|
881
|
+
* @param sources - 源对象
|
|
882
|
+
* @returns 合并后的对象
|
|
883
|
+
* @example
|
|
884
|
+
* merge({ a: 1 }, { b: 2 }, { c: 3 }) // { a: 1, b: 2, c: 3 }
|
|
885
|
+
*/
|
|
886
|
+
export declare function objectMerge<T extends object>(target: T, ...sources: Partial<T>[]): T;
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* 设置对象指定路径的值
|
|
890
|
+
* @param obj - 对象
|
|
891
|
+
* @param path - 路径,例如 'a.b.c'
|
|
892
|
+
* @param value - 要设置的值
|
|
893
|
+
* @example
|
|
894
|
+
* set({}, 'a.b.c', 1) // { a: { b: { c: 1 } } }
|
|
895
|
+
*/
|
|
896
|
+
export declare function objectSet(obj: any, path: string, value: any): void;
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* 监听节点树变更
|
|
900
|
+
* @param {Node} dom
|
|
901
|
+
* @param {Function} callback
|
|
902
|
+
* @param {Boolean} includeElementChanged 是否包含表单元素的值变更
|
|
903
|
+
*/
|
|
904
|
+
export declare const onDomTreeChange: (dom: HTMLElement, callback: () => void, includeElementChanged?: boolean) => void;
|
|
905
|
+
|
|
906
|
+
export declare const ONE_DAY: number;
|
|
907
|
+
|
|
908
|
+
export declare const ONE_HOUR: number;
|
|
909
|
+
|
|
910
|
+
export declare const ONE_MINUTE: number;
|
|
911
|
+
|
|
912
|
+
export declare const ONE_MONTH30: number;
|
|
913
|
+
|
|
914
|
+
export declare const ONE_MONTH31: number;
|
|
915
|
+
|
|
916
|
+
export declare const ONE_WEEK: number;
|
|
917
|
+
|
|
918
|
+
export declare const ONE_YEAR365: number;
|
|
919
|
+
|
|
920
|
+
export declare const ONE_YEAR366: number;
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* 非自关闭标签
|
|
924
|
+
* https://www.w3schools.com/html/html_blocks.asp
|
|
925
|
+
* @type {*[]}
|
|
926
|
+
*/
|
|
927
|
+
export declare const PAIR_TAGS: string[];
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* 精度位数转小数表示法
|
|
931
|
+
* @param {Number} precision 精度位数
|
|
932
|
+
* @returns {Float} 精度小数表示法,如 0.01
|
|
933
|
+
*/
|
|
934
|
+
export declare const precisionToStep: (precision: number) => number;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* 打印调用堆栈
|
|
938
|
+
*/
|
|
939
|
+
export declare const printStack: () => void;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* 随机整数
|
|
943
|
+
* @param {Number} min
|
|
944
|
+
* @param {Number} max
|
|
945
|
+
* @return {Number}
|
|
946
|
+
*/
|
|
947
|
+
export declare const randomInt: (min: number, max: number) => number;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* 产生随机字符串
|
|
951
|
+
* @param {Number} length
|
|
952
|
+
* @param {String} sourceStr
|
|
953
|
+
* @returns {String}
|
|
954
|
+
*/
|
|
955
|
+
export declare const randomString: (length?: number, sourceStr?: string) => string;
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* 产生随机单词
|
|
959
|
+
* @param {Number} count 单词数量
|
|
960
|
+
* @param {Number} letterMax 每个单词最大字符数量
|
|
961
|
+
* @return {String[]} 单词列表
|
|
962
|
+
*/
|
|
963
|
+
export declare const randomWords: (count?: number, letterMax?: number) => string[];
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* 矩形相交(包括边重叠情况)
|
|
967
|
+
* @param {Object} rect1
|
|
968
|
+
* @param {Object} rect2
|
|
969
|
+
* @returns {boolean}
|
|
970
|
+
*/
|
|
971
|
+
export declare const rectAssoc: (rect1: Dimension, rect2: Dimension) => boolean;
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* 检测矩形是否在指定布局内部
|
|
975
|
+
* @param rect
|
|
976
|
+
* @param layout
|
|
977
|
+
* @returns {*}
|
|
978
|
+
*/
|
|
979
|
+
export declare const rectInLayout: (rect: Dimension, layout: Dimension) => boolean;
|
|
980
|
+
|
|
981
|
+
declare interface RectObject {
|
|
982
|
+
top: number;
|
|
983
|
+
left: number;
|
|
984
|
+
right: number;
|
|
985
|
+
bottom: number;
|
|
986
|
+
width: number;
|
|
987
|
+
height: number;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* 正则表达式转义
|
|
992
|
+
* @param str
|
|
993
|
+
* @returns {string}
|
|
994
|
+
*/
|
|
995
|
+
export declare const regQuote: (str: string) => string;
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* 非内容可清理标签
|
|
999
|
+
* @type {string[]}
|
|
1000
|
+
*/
|
|
1001
|
+
export declare const REMOVABLE_TAGS: string[];
|
|
1002
|
+
|
|
1003
|
+
export declare const remove: (dom: HTMLElement | string) => Node | null;
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* 取整
|
|
1007
|
+
* @param {Number} num
|
|
1008
|
+
* @param {Number} precision 精度,默认为两位小数
|
|
1009
|
+
* @returns {number}
|
|
1010
|
+
*/
|
|
1011
|
+
export declare const round: (num: number, precision?: number) => number;
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* 过滤字符串为合法文件名
|
|
1015
|
+
* 替换 Windows/Unix 不允许的字符为下划线
|
|
1016
|
+
* 包括:\ / : * ? " < > | 以及控制字符
|
|
1017
|
+
* @param {string} name
|
|
1018
|
+
* @returns {string}
|
|
1019
|
+
*/
|
|
1020
|
+
export declare const sanitizeFileName: (name: string) => string;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* 自关闭标签
|
|
1024
|
+
* @type {string[]}
|
|
1025
|
+
*/
|
|
1026
|
+
export declare const SELF_CLOSING_TAGS: string[];
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* 设置cookie
|
|
1030
|
+
* @param {String} name
|
|
1031
|
+
* @param {String} value
|
|
1032
|
+
* @param {Number} days
|
|
1033
|
+
* @param {String} path
|
|
1034
|
+
*/
|
|
1035
|
+
export declare const setCookie: (name: string, value: string, days: number, path?: string) => void;
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* 显示节点(通过设置display为空方式)
|
|
1039
|
+
* @param {HTMLElement} dom
|
|
1040
|
+
* @param dom
|
|
1041
|
+
*/
|
|
1042
|
+
export declare const show: (dom: HTMLElement | string) => void;
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* 通过ImageSrc获取base64(网络请求模式)
|
|
1046
|
+
* @param src
|
|
1047
|
+
* @returns {Promise<unknown>}
|
|
1048
|
+
*/
|
|
1049
|
+
export declare const srcToBase64: (src: string, cache?: boolean) => Promise<unknown>;
|
|
1050
|
+
|
|
1051
|
+
export declare const STAND_DPI = 96;
|
|
1052
|
+
|
|
1053
|
+
export declare const stringToEntity: (str: string, radix?: number) => string;
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* 反转义字符串
|
|
1057
|
+
* @param str
|
|
1058
|
+
* @returns {string}
|
|
1059
|
+
* @description:
|
|
1060
|
+
* discuss at: https://locutus.io/php/stripslashes/
|
|
1061
|
+
* original by: Kevin van Zonneveld (https://kvz.io)
|
|
1062
|
+
* improved by: Ates Goral (https://magnetiq.com)
|
|
1063
|
+
* improved by: marrtins
|
|
1064
|
+
* improved by: rezna
|
|
1065
|
+
* fixed by: Mick@el
|
|
1066
|
+
* bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
|
|
1067
|
+
* bugfixed by: Brett Zamir (https://brett-zamir.me)
|
|
1068
|
+
* input by: Rick Waldron
|
|
1069
|
+
* input by: Brant Messenger (https://www.brantmessenger.com/)
|
|
1070
|
+
* reimplemented by: Brett Zamir (https://brett-zamir.me)
|
|
1071
|
+
* example 1: stripslashes('Kevin\'s code')
|
|
1072
|
+
* returns 1: "Kevin's code"
|
|
1073
|
+
* example 2: stripslashes('Kevin\\\'s code')
|
|
1074
|
+
* returns 2: "Kevin\'s code"
|
|
1075
|
+
*/
|
|
1076
|
+
export declare const stripSlashes: (str: string) => string;
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* 字符串转成首字母大写
|
|
1080
|
+
* @param {String} str
|
|
1081
|
+
* @param {Boolean} capitalize_first 是否将第一个单词首字母大写
|
|
1082
|
+
* @return {string}
|
|
1083
|
+
*/
|
|
1084
|
+
export declare const strToPascalCase: (str: string, capitalize_first?: boolean) => string;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* 节流
|
|
1088
|
+
* 规定在一个单位时间内,只能触发一次函数。如果这个函数单位时间内触发多次函数,只有一次生效。
|
|
1089
|
+
* @param {Function} fn
|
|
1090
|
+
* @param {Number} intervalMiSec
|
|
1091
|
+
* @return {(function(): void)|*}
|
|
1092
|
+
*/
|
|
1093
|
+
export declare const throttle: (fn: Function, intervalMiSec: number) => Function;
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* 更有效果的节流函数
|
|
1097
|
+
* 区别:如果函数执行间隔还没到期,放入下一个时间周期执行,如果已经有下一周期未执行,当前触发作废。
|
|
1098
|
+
* 这种效果在 **Change 类型函数场景中更有效果,可以确保最后一次变更能够有效执行
|
|
1099
|
+
* @param {Function} fn
|
|
1100
|
+
* @param {Number} intervalMiSec
|
|
1101
|
+
*/
|
|
1102
|
+
export declare const throttleEffect: (fn: Function, intervalMiSec: number) => Function;
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* 禁用启用元素切换
|
|
1106
|
+
* @param {String|Node} el
|
|
1107
|
+
* @param {String} disabledClass
|
|
1108
|
+
* @param {Boolean|Null} forceEnabled 强制启用、禁用,为空表示自动切换
|
|
1109
|
+
*/
|
|
1110
|
+
export declare const toggleDisabled: (el: HTMLElement | string, disabledClass?: string, forceEnabled?: boolean | null) => void;
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* 切换全屏
|
|
1114
|
+
* @param element
|
|
1115
|
+
* @returns {Promise<unknown>}
|
|
1116
|
+
*/
|
|
1117
|
+
export declare const toggleFullScreen: (element: any) => Promise<unknown>;
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* 去除字符串首尾指定字符或空白
|
|
1121
|
+
* @param {String} str 源字符串
|
|
1122
|
+
* @param {String} chars 指定字符,默认为空白
|
|
1123
|
+
* @param {Number} dir 方向
|
|
1124
|
+
* @returns {*|boolean}
|
|
1125
|
+
*/
|
|
1126
|
+
export declare const trim: (str: string, chars?: string, dir?: number) => string;
|
|
1127
|
+
|
|
1128
|
+
export declare const TRIM_BOTH = 0;
|
|
1129
|
+
|
|
1130
|
+
export declare const TRIM_LEFT = 1;
|
|
1131
|
+
|
|
1132
|
+
export declare const TRIM_RIGHT = 2;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* 截断字符串
|
|
1136
|
+
* @param str - 输入字符串
|
|
1137
|
+
* @param length - 最大长度
|
|
1138
|
+
* @param suffix - 后缀,默认为 '...'
|
|
1139
|
+
* @returns 截断后的字符串
|
|
1140
|
+
* @example
|
|
1141
|
+
* truncate('hello world', 5) // 'hello...'
|
|
1142
|
+
*/
|
|
1143
|
+
export declare function truncate(str: string, length: number, suffix?: string): string;
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* 反转义HTML
|
|
1147
|
+
* @param {String} html
|
|
1148
|
+
* @returns {string}
|
|
1149
|
+
*/
|
|
1150
|
+
export declare const unescapeHtml: (html: string) => string;
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* url 转 Base64Data 数据缓存
|
|
1154
|
+
* @param {String} url
|
|
1155
|
+
* @param {String|Null} b64Data base64 数据,传入 null 则为读取缓存,这里不是不是base64,而是 base64 data URL
|
|
1156
|
+
* @returns {String|Null} 读取缓存时返回 base64 data URL 字符串,未命中返回 null
|
|
1157
|
+
*/
|
|
1158
|
+
export declare const urlB64DataCache: (url: string, b64Data?: string | null) => string | null;
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* @param {String} srcStr
|
|
1162
|
+
* @return {string}
|
|
1163
|
+
*/
|
|
1164
|
+
export declare const utf8Decode: (srcStr: string) => string;
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* @param {String} srcStr
|
|
1168
|
+
* @returns {string}
|
|
1169
|
+
*/
|
|
1170
|
+
export declare const utf8Encode: (srcStr: string) => string;
|
|
1171
|
+
|
|
1172
|
+
export declare const WEEK_DAY_NAMES_CN: string[];
|
|
1173
|
+
|
|
1174
|
+
export declare const WEEK_DAY_NAMES_SHORT_CN: string[];
|
|
1175
|
+
|
|
1176
|
+
export declare const YEAR_NOW: number;
|
|
1177
|
+
|
|
1178
|
+
export { }
|