sculp-js 0.1.1 → 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 +3 -0
- package/lib/cjs/array.js +29 -23
- package/lib/cjs/async.js +3 -3
- package/lib/cjs/clipboard.js +3 -3
- package/lib/cjs/cookie.js +5 -5
- package/lib/cjs/date.js +130 -12
- package/lib/cjs/dom.js +13 -11
- package/lib/cjs/download.js +9 -9
- package/lib/cjs/easing.js +1 -1
- package/lib/cjs/file.js +5 -4
- package/lib/cjs/func.js +1 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/number.js +4 -4
- package/lib/cjs/object.js +11 -9
- package/lib/cjs/path.js +1 -1
- package/lib/cjs/qs.js +5 -5
- package/lib/cjs/random.js +1 -1
- package/lib/cjs/string.js +8 -8
- package/lib/cjs/type.js +11 -2
- package/lib/cjs/unique.js +1 -1
- package/lib/cjs/url.js +1 -1
- package/lib/cjs/watermark.js +8 -9
- package/lib/es/array.js +29 -23
- package/lib/es/async.js +3 -3
- package/lib/es/clipboard.js +3 -3
- package/lib/es/cookie.js +5 -5
- package/lib/es/date.js +127 -13
- package/lib/es/dom.js +13 -11
- package/lib/es/download.js +9 -9
- package/lib/es/easing.js +1 -1
- package/lib/es/file.js +5 -4
- package/lib/es/func.js +1 -1
- package/lib/es/index.js +2 -2
- package/lib/es/number.js +4 -4
- package/lib/es/object.js +11 -9
- package/lib/es/path.js +1 -1
- package/lib/es/qs.js +5 -5
- package/lib/es/random.js +1 -1
- package/lib/es/string.js +8 -8
- package/lib/es/type.js +11 -2
- package/lib/es/unique.js +1 -1
- package/lib/es/url.js +1 -1
- package/lib/es/watermark.js +8 -9
- package/lib/index.d.ts +121 -62
- package/lib/umd/index.js +229 -94
- package/package.json +3 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
/** 任意函数 */
|
|
1
2
|
type AnyFunc<R = any> = (...args: any[]) => R;
|
|
3
|
+
/** 任意数组 */
|
|
2
4
|
type AnyArray = any[];
|
|
5
|
+
/** 取出数组元素 */
|
|
3
6
|
type ArrayElements<A> = A extends Array<infer R> ? R : never;
|
|
7
|
+
/** 任意对象 */
|
|
4
8
|
type AnyObject = Record<string | number, any>;
|
|
5
9
|
type PartialDeep<T> = {
|
|
6
10
|
[P in keyof T]?: PartialDeep<T[P]>;
|
|
7
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 判断任意值的数据类型
|
|
14
|
+
* @param {unknown} any
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
8
17
|
declare const typeIs: (any: unknown) => string;
|
|
9
18
|
declare const isString: (any: unknown) => any is string;
|
|
10
19
|
declare const isBoolean: (any: unknown) => any is boolean;
|
|
@@ -16,6 +25,11 @@ declare const isNull: (any: unknown) => any is null;
|
|
|
16
25
|
declare const isPrimitive: (any: unknown) => boolean;
|
|
17
26
|
declare const isObject: (any: unknown) => any is Record<string, unknown>;
|
|
18
27
|
declare const isArray: (any: unknown) => any is unknown[];
|
|
28
|
+
/**
|
|
29
|
+
* 判断是否为函数
|
|
30
|
+
* @param {unknown} any
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
19
33
|
declare const isFunction: (any: unknown) => any is Function;
|
|
20
34
|
declare const isNaN: (any: unknown) => any is number;
|
|
21
35
|
declare const isDate: (any: unknown) => any is Date;
|
|
@@ -24,22 +38,25 @@ declare const isRegExp: (any: unknown) => any is RegExp;
|
|
|
24
38
|
|
|
25
39
|
/**
|
|
26
40
|
* 判断一个对象是否为类数组
|
|
41
|
+
*
|
|
27
42
|
* @param any
|
|
28
43
|
* @returns {boolean}
|
|
29
44
|
*/
|
|
30
|
-
declare
|
|
45
|
+
declare function arrayLike(any: unknown): boolean;
|
|
31
46
|
/**
|
|
32
47
|
* 遍历数组,返回 false 中断遍历
|
|
48
|
+
*
|
|
33
49
|
* @param {ArrayLike<V>} array
|
|
34
50
|
* @param {(val: V, idx: number) => any} iterator
|
|
35
51
|
* @param reverse {boolean} 是否倒序
|
|
52
|
+
* @returns {*}
|
|
36
53
|
*/
|
|
37
|
-
declare
|
|
54
|
+
declare function arrayEach<V>(array: ArrayLike<V>, iterator: (val: V, idx: number, arr: ArrayLike<V>) => any, reverse?: boolean): void;
|
|
38
55
|
/**
|
|
39
56
|
* 异步遍历数组,返回 false 中断遍历
|
|
40
|
-
* @param {ArrayLike<V>} array
|
|
41
|
-
* @param {(val: V, idx: number) => Promise<any>} iterator
|
|
42
|
-
* @param {boolean} reverse
|
|
57
|
+
* @param {ArrayLike<V>} array 数组
|
|
58
|
+
* @param {(val: V, idx: number) => Promise<any>} iterator 支持Promise类型的回调函数
|
|
59
|
+
* @param {boolean} reverse 是否反向遍历
|
|
43
60
|
*/
|
|
44
61
|
declare function arrayEachAsync<V>(array: ArrayLike<V>, iterator: (val: V, idx: number) => Promise<any> | any, reverse?: boolean): Promise<void>;
|
|
45
62
|
/**
|
|
@@ -47,8 +64,9 @@ declare function arrayEachAsync<V>(array: ArrayLike<V>, iterator: (val: V, idx:
|
|
|
47
64
|
* @param {AnyArray} array
|
|
48
65
|
* @param {number} start
|
|
49
66
|
* @param {number} to
|
|
67
|
+
* @returns {*}
|
|
50
68
|
*/
|
|
51
|
-
declare
|
|
69
|
+
declare function arrayInsertBefore(array: AnyArray, start: number, to: number): void;
|
|
52
70
|
/**
|
|
53
71
|
* 数组删除指定项目
|
|
54
72
|
* @param {V[]} array
|
|
@@ -58,12 +76,13 @@ declare const arrayInsertBefore: (array: AnyArray, start: number, to: number) =>
|
|
|
58
76
|
declare function arrayRemove<V>(array: V[], expect: (val: V, idx: number) => boolean): V[];
|
|
59
77
|
/**
|
|
60
78
|
* 自定义深度优先遍历函数(支持continue和break操作)
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {boolean} isReverse
|
|
79
|
+
* @param {ArrayLike<V>} tree 树形数据
|
|
80
|
+
* @param {Function} iterator 迭代函数
|
|
81
|
+
* @param {string} children 定制子元素的key
|
|
82
|
+
* @param {boolean} isReverse 是否反向遍历
|
|
83
|
+
* @returns {*}
|
|
65
84
|
*/
|
|
66
|
-
declare
|
|
85
|
+
declare function deepTraversal<V>(tree: ArrayLike<V>, iterator: (val: V, i: number, arr: ArrayLike<V>, parent: V | null, level: number) => any, children?: string, isReverse?: boolean): void;
|
|
67
86
|
type IdLike = number | string;
|
|
68
87
|
interface ITreeConf {
|
|
69
88
|
id: string | number;
|
|
@@ -71,10 +90,11 @@ interface ITreeConf {
|
|
|
71
90
|
}
|
|
72
91
|
/**
|
|
73
92
|
* 在树中找到 id 为某个值的节点,并返回上游的所有父级节点
|
|
74
|
-
*
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {
|
|
77
|
-
* @
|
|
93
|
+
*
|
|
94
|
+
* @param {ArrayLike<T>} tree - 树形数据
|
|
95
|
+
* @param {IdLike} nodeId - 元素ID
|
|
96
|
+
* @param {ITreeConf} config - 迭代配置项
|
|
97
|
+
* @returns {[IdLike[], ITreeItem<V>[]]} - 由parentId...childId, parentObject-childObject组成的二维数组
|
|
78
98
|
*/
|
|
79
99
|
declare function getTreeIds<V>(tree: ArrayLike<V>, nodeId: IdLike, config?: ITreeConf): [IdLike[], ArrayLike<V>[]];
|
|
80
100
|
|
|
@@ -82,27 +102,38 @@ declare function getTreeIds<V>(tree: ArrayLike<V>, nodeId: IdLike, config?: ITre
|
|
|
82
102
|
* 复制文本
|
|
83
103
|
* @param {string} text
|
|
84
104
|
*/
|
|
85
|
-
declare
|
|
105
|
+
declare function copyText(text: string): void;
|
|
86
106
|
|
|
87
107
|
/**
|
|
88
108
|
* 获取cookie
|
|
89
109
|
* @param {string} name
|
|
90
110
|
* @returns {string}
|
|
91
111
|
*/
|
|
92
|
-
declare
|
|
112
|
+
declare function cookieGet(name: string): string;
|
|
93
113
|
/**
|
|
94
114
|
* 设置 cookie
|
|
95
115
|
* @param {string} name
|
|
96
116
|
* @param {string} value
|
|
97
117
|
* @param {number | Date} [maxAge]
|
|
98
118
|
*/
|
|
99
|
-
declare
|
|
119
|
+
declare function cookieSet(name: string, value: string, maxAge?: number | Date): void;
|
|
100
120
|
/**
|
|
101
121
|
* 删除单个 cookie
|
|
102
122
|
* @param name cookie 名称
|
|
103
123
|
*/
|
|
104
124
|
declare const cookieDel: (name: string) => void;
|
|
105
125
|
|
|
126
|
+
declare const isValidDate: (any: unknown) => any is Date;
|
|
127
|
+
interface DateObj {
|
|
128
|
+
[propName: string]: string;
|
|
129
|
+
}
|
|
130
|
+
type DateValue = number | string | Date;
|
|
131
|
+
/**
|
|
132
|
+
* 解析为Date对象
|
|
133
|
+
* @param {DateValue} value - 可以是数值、字符串或 Date 对象
|
|
134
|
+
* @returns {Date} - 转换后的目标Date
|
|
135
|
+
*/
|
|
136
|
+
declare function dateParse(value: DateValue): Date;
|
|
106
137
|
/**
|
|
107
138
|
* 格式化为日期对象(带自定义格式化模板)
|
|
108
139
|
* @param {DateValue} value 可以是数值、字符串或 Date 对象
|
|
@@ -117,24 +148,52 @@ declare const cookieDel: (name: string) => void;
|
|
|
117
148
|
* - mm:分
|
|
118
149
|
* - ss:秒
|
|
119
150
|
* - SSS:毫秒
|
|
120
|
-
* - ww: 周
|
|
121
151
|
* @returns {string}
|
|
122
152
|
*/
|
|
123
|
-
|
|
153
|
+
/**
|
|
154
|
+
* 将日期转换为一天的开始时间,即0点0分0秒0毫秒
|
|
155
|
+
* @param {DateValue} value
|
|
156
|
+
* @returns {Date}
|
|
157
|
+
*/
|
|
158
|
+
declare function dateToStart(value: DateValue): Date;
|
|
159
|
+
/**
|
|
160
|
+
* 将日期转换为一天的结束时间,即23点59分59秒999毫秒
|
|
161
|
+
* @param {DateValue} value
|
|
162
|
+
* @returns {Date}
|
|
163
|
+
*/
|
|
164
|
+
declare function dateToEnd(value: DateValue): Date;
|
|
165
|
+
/**
|
|
166
|
+
* 格式化为日期对象(带自定义格式化模板)
|
|
167
|
+
* @param {Date} value - 可以是数值、字符串或 Date 对象
|
|
168
|
+
* @param {string} [format] - 模板,默认是 YYYY-MM-DD HH:mm:ss,模板字符:
|
|
169
|
+
* - YYYY:年
|
|
170
|
+
* - yyyy: 年
|
|
171
|
+
* - MM:月
|
|
172
|
+
* - DD:日
|
|
173
|
+
* - dd: 日
|
|
174
|
+
* - HH:时(24 小时制)
|
|
175
|
+
* - hh:时(12 小时制)
|
|
176
|
+
* - mm:分
|
|
177
|
+
* - ss:秒
|
|
178
|
+
* - SSS:毫秒
|
|
179
|
+
* - ww: 周
|
|
180
|
+
* @returns {string} 格式化后的日期字符串
|
|
181
|
+
*/
|
|
182
|
+
declare function formatDate(value: DateValue, format?: string): string;
|
|
124
183
|
/**
|
|
125
184
|
* 计算向前或向后N天的具体日期
|
|
126
|
-
* @param {string} strDate 参考日期
|
|
127
|
-
* @param {number} n 正数:向后推算;负数:向前推算
|
|
128
|
-
* @param {string} sep 日期格式的分隔符
|
|
129
|
-
* @
|
|
185
|
+
* @param {string} strDate - 参考日期
|
|
186
|
+
* @param {number} n - 正数:向后推算;负数:向前推算
|
|
187
|
+
* @param {string} sep - 日期格式的分隔符
|
|
188
|
+
* @returns {string} 计算后的目标日期
|
|
130
189
|
*/
|
|
131
190
|
declare function calculateDate(strDate: string, n: number, sep?: string): string;
|
|
132
191
|
/**
|
|
133
192
|
* 计算向前或向后N天的具体时间日期
|
|
134
|
-
* @param {number} n 正数:向后推算;负数:向前推算
|
|
135
|
-
* @param {string} dateSep 日期分隔符
|
|
136
|
-
* @param {string} timeSep 时间分隔符
|
|
137
|
-
* @
|
|
193
|
+
* @param {number} n - 正数:向后推算;负数:向前推算
|
|
194
|
+
* @param {string} dateSep - 日期分隔符
|
|
195
|
+
* @param {string} timeSep - 时间分隔符
|
|
196
|
+
* @returns {string} 转换后的目标日期时间
|
|
138
197
|
*/
|
|
139
198
|
declare function calculateDateTime(n: number, dateSep?: string, timeSep?: string): string;
|
|
140
199
|
|
|
@@ -149,19 +208,19 @@ interface Style {
|
|
|
149
208
|
* @param {string} className
|
|
150
209
|
* @returns {boolean}
|
|
151
210
|
*/
|
|
152
|
-
declare
|
|
211
|
+
declare function hasClass(el: HTMLElement, className: string): boolean;
|
|
153
212
|
/**
|
|
154
213
|
* 给元素增加样式名
|
|
155
214
|
* @param {HTMLElement} el
|
|
156
215
|
* @param {string} classNames
|
|
157
216
|
*/
|
|
158
|
-
declare
|
|
217
|
+
declare function addClass(el: HTMLElement, classNames: string): void;
|
|
159
218
|
/**
|
|
160
219
|
* 给元素移除样式名
|
|
161
220
|
* @param {HTMLElement} el
|
|
162
221
|
* @param {string} classNames
|
|
163
222
|
*/
|
|
164
|
-
declare
|
|
223
|
+
declare function removeClass(el: HTMLElement, classNames: string): void;
|
|
165
224
|
interface SetStyle {
|
|
166
225
|
(el: HTMLElement, key: string, val: string): void;
|
|
167
226
|
(el: HTMLElement, style: Style): void;
|
|
@@ -175,11 +234,11 @@ interface SetStyle {
|
|
|
175
234
|
declare const setStyle: SetStyle;
|
|
176
235
|
/**
|
|
177
236
|
* 获取元素样式
|
|
178
|
-
* @param {HTMLElement} el
|
|
237
|
+
* @param {HTMLElement} el 元素
|
|
179
238
|
* @param {string} key
|
|
180
239
|
* @returns {string}
|
|
181
240
|
*/
|
|
182
|
-
declare
|
|
241
|
+
declare function getStyle(el: HTMLElement, key: string): string;
|
|
183
242
|
type ScrollElement = HTMLElement | Document | Window;
|
|
184
243
|
interface SmoothScrollOptions {
|
|
185
244
|
el: ScrollElement;
|
|
@@ -196,7 +255,7 @@ declare function onDomReady(callback: ReadyCallback): void;
|
|
|
196
255
|
* @param {HTMLElement} el
|
|
197
256
|
* @param {string} property
|
|
198
257
|
* @param {boolean} reNumber
|
|
199
|
-
* @
|
|
258
|
+
* @returns {string|number}
|
|
200
259
|
*/
|
|
201
260
|
declare function getComputedCssVal(el: HTMLElement, property: string, reNumber?: boolean): string | number;
|
|
202
261
|
|
|
@@ -208,7 +267,7 @@ interface Params<T = string | number> {
|
|
|
208
267
|
* @param {string} queryString
|
|
209
268
|
* @returns {Params}
|
|
210
269
|
*/
|
|
211
|
-
declare
|
|
270
|
+
declare function qsParse(queryString: string): Params;
|
|
212
271
|
type LooseParamValue = string | number | boolean | Date | null | undefined;
|
|
213
272
|
interface LooseParams<T = LooseParamValue> {
|
|
214
273
|
[key: string]: T | Array<T>;
|
|
@@ -220,26 +279,26 @@ type Replacer = (value: LooseParamValue) => string | null;
|
|
|
220
279
|
* @param {Replacer} replacer
|
|
221
280
|
* @returns {string}
|
|
222
281
|
*/
|
|
223
|
-
declare
|
|
282
|
+
declare function qsStringify(query: LooseParams, replacer?: Replacer): string;
|
|
224
283
|
|
|
225
284
|
/**
|
|
226
285
|
* 通过打开新窗口的方式下载
|
|
227
286
|
* @param {string} url
|
|
228
287
|
* @param {LooseParams} params
|
|
229
288
|
*/
|
|
230
|
-
declare
|
|
289
|
+
declare function downloadURL(url: string, params?: LooseParams): void;
|
|
231
290
|
/**
|
|
232
291
|
* 通过 A 链接的方式下载
|
|
233
292
|
* @param {string} href
|
|
234
293
|
* @param {string} filename
|
|
235
294
|
*/
|
|
236
|
-
declare
|
|
295
|
+
declare function downloadHref(href: string, filename: string): void;
|
|
237
296
|
/**
|
|
238
297
|
* 将大文件对象通过 A 链接的方式下载
|
|
239
298
|
* @param {Blob} blob
|
|
240
299
|
* @param {string} filename
|
|
241
300
|
*/
|
|
242
|
-
declare
|
|
301
|
+
declare function downloadBlob(blob: Blob, filename: string): void;
|
|
243
302
|
type FileType = 'json' | 'csv' | 'xls' | 'xlsx';
|
|
244
303
|
/**
|
|
245
304
|
* 将指定数据格式通过 A 链接的方式下载
|
|
@@ -248,7 +307,7 @@ type FileType = 'json' | 'csv' | 'xls' | 'xlsx';
|
|
|
248
307
|
* @param {string} filename
|
|
249
308
|
* @param {string[]} [headers]
|
|
250
309
|
*/
|
|
251
|
-
declare
|
|
310
|
+
declare function downloadData(data: AnyObject | AnyObject[], fileType: FileType, filename: string, headers?: string[]): void;
|
|
252
311
|
|
|
253
312
|
/**
|
|
254
313
|
* 判断对象是否为纯对象
|
|
@@ -262,13 +321,13 @@ declare const isPlainObject: (obj: unknown) => boolean;
|
|
|
262
321
|
* @param {string} key
|
|
263
322
|
* @returns {boolean}
|
|
264
323
|
*/
|
|
265
|
-
declare
|
|
324
|
+
declare function objectHas<T extends AnyObject>(obj: T, key: keyof T): boolean;
|
|
266
325
|
/**
|
|
267
326
|
* 遍历对象,返回 false 中断遍历
|
|
268
327
|
* @param {O} obj
|
|
269
328
|
* @param {(val: O[keyof O], key: keyof O) => (boolean | void)} iterator
|
|
270
329
|
*/
|
|
271
|
-
declare
|
|
330
|
+
declare function objectEach<O extends AnyObject>(obj: O, iterator: (val: O[keyof O], key: Extract<keyof O, string>) => any): void;
|
|
272
331
|
/**
|
|
273
332
|
* 异步遍历对象,返回 false 中断遍历
|
|
274
333
|
* @param {O} obj
|
|
@@ -303,7 +362,7 @@ type ObjectAssignItem = AnyObject | AnyArray;
|
|
|
303
362
|
* @param {ObjectAssignItem | undefined} targets
|
|
304
363
|
* @returns {R}
|
|
305
364
|
*/
|
|
306
|
-
declare
|
|
365
|
+
declare function objectAssign<R = AnyObject | AnyArray>(source: ObjectAssignItem, ...targets: (ObjectAssignItem | undefined)[]): R;
|
|
307
366
|
|
|
308
367
|
/**
|
|
309
368
|
* 对象填充
|
|
@@ -312,7 +371,7 @@ declare const objectAssign: <R = AnyObject | AnyArray>(source: ObjectAssignItem,
|
|
|
312
371
|
* @param {(s: Partial<R>, t: Partial<R>, key: keyof R) => boolean} fillable
|
|
313
372
|
* @returns {R}
|
|
314
373
|
*/
|
|
315
|
-
declare
|
|
374
|
+
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;
|
|
316
375
|
declare function objectGet(obj: AnyObject, path: string, strict?: boolean): {
|
|
317
376
|
p: any | undefined;
|
|
318
377
|
k: string | undefined;
|
|
@@ -322,9 +381,9 @@ declare function objectGet(obj: AnyObject, path: string, strict?: boolean): {
|
|
|
322
381
|
* 深拷贝堪称完全体 即:任何类型的数据都会被深拷贝
|
|
323
382
|
* @param {AnyObject | AnyArray} obj
|
|
324
383
|
* @param {WeakMap} map
|
|
325
|
-
* @
|
|
384
|
+
* @returns {AnyObject | AnyArray}
|
|
326
385
|
*/
|
|
327
|
-
declare function cloneDeep(obj: Object, map?: WeakMap<
|
|
386
|
+
declare function cloneDeep(obj: Object, map?: WeakMap<object, any>): Object;
|
|
328
387
|
|
|
329
388
|
/**
|
|
330
389
|
* 标准化路径
|
|
@@ -346,14 +405,14 @@ declare const pathJoin: (from: string, ...to: string[]) => string;
|
|
|
346
405
|
* @param {boolean} [bigger] 是否大写第一个字母
|
|
347
406
|
* @returns {string}
|
|
348
407
|
*/
|
|
349
|
-
declare
|
|
408
|
+
declare function stringCamelCase(string: string, bigger?: boolean): string;
|
|
350
409
|
/**
|
|
351
410
|
* 将字符串转换为连字格式
|
|
352
411
|
* @param {string} string
|
|
353
412
|
* @param {string} [separator] 分隔符,默认是"-"(短横线)
|
|
354
413
|
* @returns {string}
|
|
355
414
|
*/
|
|
356
|
-
declare
|
|
415
|
+
declare function stringKebabCase(string: string, separator?: string): string;
|
|
357
416
|
declare const STRING_ARABIC_NUMERALS = "0123456789";
|
|
358
417
|
declare const STRING_LOWERCASE_ALPHA = "abcdefghijklmnopqrstuvwxyz";
|
|
359
418
|
declare const STRING_UPPERCASE_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
@@ -368,7 +427,7 @@ declare const STRING_UPPERCASE_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
368
427
|
* @param args
|
|
369
428
|
* @returns {string}
|
|
370
429
|
*/
|
|
371
|
-
declare
|
|
430
|
+
declare function stringFormat(string: string, ...args: Array<unknown>): string;
|
|
372
431
|
/**
|
|
373
432
|
* 字符串赋值
|
|
374
433
|
* @example
|
|
@@ -404,7 +463,7 @@ declare const stringFill: (length: number, value?: string) => string;
|
|
|
404
463
|
* @param {string} str 目标字符串
|
|
405
464
|
* @param {number} fontSize 字符串字体大小
|
|
406
465
|
* @param {boolean} isRemoveDom 计算后是否移除中间dom元素
|
|
407
|
-
* @
|
|
466
|
+
* @returns {*}
|
|
408
467
|
*/
|
|
409
468
|
declare function getStrWidthPx(str: string, fontSize?: number, isRemoveDom?: boolean): number;
|
|
410
469
|
|
|
@@ -470,12 +529,11 @@ declare function asyncMap<T, R>(list: Array<T>, mapper: (val: T, idx: number, li
|
|
|
470
529
|
|
|
471
530
|
/**
|
|
472
531
|
* 选择本地文件
|
|
473
|
-
* @param {
|
|
474
|
-
* @
|
|
532
|
+
* @param {string} accept 上传的文件类型,用于过滤
|
|
533
|
+
* @param {Function} changeCb 选择文件回调
|
|
534
|
+
* @returns {HTMLInputElement}
|
|
475
535
|
*/
|
|
476
|
-
declare function chooseLocalFile(
|
|
477
|
-
accept: any;
|
|
478
|
-
}, changeCb: (FileList: any) => any): HTMLInputElement;
|
|
536
|
+
declare function chooseLocalFile(accept: string, changeCb: (FileList: any) => any): HTMLInputElement;
|
|
479
537
|
|
|
480
538
|
interface ICanvasWM {
|
|
481
539
|
container: HTMLElement;
|
|
@@ -490,10 +548,11 @@ interface ICanvasWM {
|
|
|
490
548
|
zIndex: number;
|
|
491
549
|
}
|
|
492
550
|
/**
|
|
493
|
-
* canvas 实现
|
|
551
|
+
* canvas 实现 水印, 具备防删除功能
|
|
494
552
|
* @param {ICanvasWM} canvasWM
|
|
553
|
+
* @example genCanvasWM({ content: 'QQMusicFE' })
|
|
495
554
|
*/
|
|
496
|
-
declare
|
|
555
|
+
declare function genCanvasWM(canvasWM: ICanvasWM): void;
|
|
497
556
|
|
|
498
557
|
interface DebounceFunc<F extends AnyFunc> {
|
|
499
558
|
(...args: Parameters<F>): void;
|
|
@@ -551,7 +610,7 @@ declare function getGlobal<T>(key: string | number | symbol): T | void;
|
|
|
551
610
|
* @returns {number}
|
|
552
611
|
*/
|
|
553
612
|
declare const randomNumber: (min: number, max: number) => number;
|
|
554
|
-
declare const STRING_POOL
|
|
613
|
+
declare const STRING_POOL: string;
|
|
555
614
|
interface RandomString {
|
|
556
615
|
(length: number, pool: string): string;
|
|
557
616
|
(length: number): string;
|
|
@@ -571,14 +630,14 @@ declare const randomString: RandomString;
|
|
|
571
630
|
*/
|
|
572
631
|
declare function randomUuid(): string;
|
|
573
632
|
|
|
574
|
-
declare const HEX_POOL
|
|
633
|
+
declare const HEX_POOL: string;
|
|
575
634
|
/**
|
|
576
635
|
* 将十进制转换成任意进制
|
|
577
636
|
* @param {number | string} decimal 十进制数值或字符串,可以是任意长度,会使用大数进行计算
|
|
578
637
|
* @param {string} [hexPool] 进制池,默认 62 进制
|
|
579
638
|
* @returns {string}
|
|
580
639
|
*/
|
|
581
|
-
declare
|
|
640
|
+
declare function numberToHex(decimal: number | string, hexPool?: string): string;
|
|
582
641
|
/**
|
|
583
642
|
* 缩写
|
|
584
643
|
* @param {number | string} num
|
|
@@ -592,7 +651,7 @@ declare const numberAbbr: (num: number | string, units: Array<string>, ratio?: n
|
|
|
592
651
|
* 将数字格式化成千位分隔符显示的字符串
|
|
593
652
|
* @param {number} val 数字
|
|
594
653
|
* @param {'int' | 'float'} type 展示分段显示的类型 int:整型 | float:浮点型
|
|
595
|
-
* @
|
|
654
|
+
* @returns {string}
|
|
596
655
|
*/
|
|
597
656
|
declare function formatNumber(val: number, type?: string): string;
|
|
598
657
|
|
|
@@ -617,4 +676,4 @@ interface UniqueString {
|
|
|
617
676
|
*/
|
|
618
677
|
declare const uniqueString: UniqueString;
|
|
619
678
|
|
|
620
|
-
export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, HEX_POOL, type LooseParamValue, type LooseParams, type Params, type PartialDeep, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, UNIQUE_NUMBER_SAFE_LENGTH, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, cookieDel, cookieGet, cookieSet, copyText, debounce, deepTraversal, downloadBlob, downloadData, downloadHref, downloadURL, formatDate, formatNumber, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, getTreeIds, hasClass, isArray, isBigInt, isBoolean, isDate, isDomReady, isError, isFunction, isNaN, isNull, isNumber, isObject, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, throttle, typeIs, uniqueNumber, uniqueString, urlDelParams, urlParse, urlSetParams, urlStringify, wait };
|
|
679
|
+
export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type DateObj, type DateValue, type DebounceFunc, type FileType, HEX_POOL, type ICanvasWM, type ITreeConf, type IdLike, type LooseParamValue, type LooseParams, type ObjectAssignItem, type OnceFunc, type Params, type PartialDeep, type RandomString, type ReadyCallback, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, type SetStyle, type SmoothScrollOptions, type Style, type ThrottleFunc, UNIQUE_NUMBER_SAFE_LENGTH, type UniqueString, type Url, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, cookieDel, cookieGet, cookieSet, copyText, dateParse, dateToEnd, dateToStart, debounce, deepTraversal, downloadBlob, downloadData, downloadHref, downloadURL, formatDate, formatNumber, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, getTreeIds, hasClass, isArray, isBigInt, isBoolean, isDate, isDomReady, isError, isFunction, isNaN, isNull, isNumber, isObject, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, isValidDate, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, throttle, typeIs, uniqueNumber, uniqueString, urlDelParams, urlParse, urlSetParams, urlStringify, wait };
|