sculp-js 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +19 -1
- package/lib/cjs/array.js +4 -33
- package/lib/cjs/async.js +1 -1
- package/lib/cjs/clipboard.js +1 -1
- package/lib/cjs/cookie.js +1 -1
- package/lib/cjs/date.js +13 -13
- package/lib/cjs/dom.js +13 -1
- package/lib/cjs/download.js +1 -1
- package/lib/cjs/easing.js +1 -1
- package/lib/cjs/file.js +1 -1
- package/lib/cjs/func.js +160 -0
- package/lib/cjs/index.js +97 -15
- package/lib/cjs/number.js +82 -0
- package/lib/cjs/object.js +3 -3
- package/lib/cjs/path.js +1 -1
- package/lib/cjs/qs.js +1 -1
- package/lib/cjs/random.js +72 -0
- package/lib/cjs/string.js +34 -1
- package/lib/cjs/type.js +2 -1
- package/lib/cjs/unique.js +83 -0
- package/lib/cjs/url.js +1 -1
- package/lib/cjs/watermark.js +1 -1
- package/lib/es/array.js +5 -33
- package/lib/es/async.js +1 -1
- package/lib/es/clipboard.js +1 -1
- package/lib/es/cookie.js +1 -1
- package/lib/es/date.js +13 -13
- package/lib/es/dom.js +13 -2
- package/lib/es/download.js +1 -1
- package/lib/es/easing.js +1 -1
- package/lib/es/file.js +1 -1
- package/lib/es/func.js +154 -0
- package/lib/es/index.js +19 -29
- package/lib/es/number.js +77 -0
- package/lib/es/object.js +2 -2
- package/lib/es/path.js +1 -1
- package/lib/es/qs.js +1 -1
- package/lib/es/random.js +67 -0
- package/lib/es/string.js +34 -2
- package/lib/es/type.js +2 -2
- package/lib/es/unique.js +79 -0
- package/lib/es/url.js +1 -1
- package/lib/es/watermark.js +1 -1
- package/lib/index.d.ts +140 -164
- package/lib/umd/index.js +488 -189
- package/package.json +33 -7
package/lib/index.d.ts
CHANGED
|
@@ -22,30 +22,6 @@ declare const isDate: (any: unknown) => any is Date;
|
|
|
22
22
|
declare const isError: (any: unknown) => any is Error;
|
|
23
23
|
declare const isRegExp: (any: unknown) => any is RegExp;
|
|
24
24
|
|
|
25
|
-
type type_AnyArray = AnyArray;
|
|
26
|
-
type type_AnyFunc<R = any> = AnyFunc<R>;
|
|
27
|
-
type type_AnyObject = AnyObject;
|
|
28
|
-
type type_ArrayElements<A> = ArrayElements<A>;
|
|
29
|
-
type type_PartialDeep<T> = PartialDeep<T>;
|
|
30
|
-
declare const type_isArray: typeof isArray;
|
|
31
|
-
declare const type_isBigInt: typeof isBigInt;
|
|
32
|
-
declare const type_isBoolean: typeof isBoolean;
|
|
33
|
-
declare const type_isDate: typeof isDate;
|
|
34
|
-
declare const type_isError: typeof isError;
|
|
35
|
-
declare const type_isFunction: typeof isFunction;
|
|
36
|
-
declare const type_isNaN: typeof isNaN;
|
|
37
|
-
declare const type_isNull: typeof isNull;
|
|
38
|
-
declare const type_isNumber: typeof isNumber;
|
|
39
|
-
declare const type_isObject: typeof isObject;
|
|
40
|
-
declare const type_isPrimitive: typeof isPrimitive;
|
|
41
|
-
declare const type_isRegExp: typeof isRegExp;
|
|
42
|
-
declare const type_isString: typeof isString;
|
|
43
|
-
declare const type_isSymbol: typeof isSymbol;
|
|
44
|
-
declare const type_isUndefined: typeof isUndefined;
|
|
45
|
-
declare namespace type {
|
|
46
|
-
export { type type_AnyArray as AnyArray, type type_AnyFunc as AnyFunc, type type_AnyObject as AnyObject, type type_ArrayElements as ArrayElements, type type_PartialDeep as PartialDeep, typeIs as default, type_isArray as isArray, type_isBigInt as isBigInt, type_isBoolean as isBoolean, type_isDate as isDate, type_isError as isError, type_isFunction as isFunction, type_isNaN as isNaN, type_isNull as isNull, type_isNumber as isNumber, type_isObject as isObject, type_isPrimitive as isPrimitive, type_isRegExp as isRegExp, type_isString as isString, type_isSymbol as isSymbol, type_isUndefined as isUndefined };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
25
|
/**
|
|
50
26
|
* 判断一个对象是否为类数组
|
|
51
27
|
* @param any
|
|
@@ -58,7 +34,7 @@ declare const arrayLike: (any: unknown) => boolean;
|
|
|
58
34
|
* @param {(val: V, idx: number) => any} iterator
|
|
59
35
|
* @param reverse {boolean} 是否倒序
|
|
60
36
|
*/
|
|
61
|
-
declare const arrayEach: <V>(array: ArrayLike<V>, iterator: (val: V, idx: number) => any, reverse?: boolean) => void;
|
|
37
|
+
declare const arrayEach: <V>(array: ArrayLike<V>, iterator: (val: V, idx: number, arr: ArrayLike<V>) => any, reverse?: boolean) => void;
|
|
62
38
|
/**
|
|
63
39
|
* 异步遍历数组,返回 false 中断遍历
|
|
64
40
|
* @param {ArrayLike<V>} array
|
|
@@ -101,42 +77,6 @@ interface ITreeConf {
|
|
|
101
77
|
* @return {[IdLike[], ITreeItem<V>[]]}
|
|
102
78
|
*/
|
|
103
79
|
declare function getTreeIds<V>(tree: ArrayLike<V>, nodeId: IdLike, config?: ITreeConf): [IdLike[], ArrayLike<V>[]];
|
|
104
|
-
/**
|
|
105
|
-
* 异步ForEach函数
|
|
106
|
-
* @param {array} array
|
|
107
|
-
* @param {asyncFuntion} callback
|
|
108
|
-
* // asyncForEach 使用范例如下
|
|
109
|
-
// const start = async () => {
|
|
110
|
-
// await asyncForEach(result, async (item) => {
|
|
111
|
-
// await request(item);
|
|
112
|
-
// count++;
|
|
113
|
-
// });
|
|
114
|
-
|
|
115
|
-
// console.log('发送次数', count);
|
|
116
|
-
// }
|
|
117
|
-
|
|
118
|
-
// for await...of 使用范例如下
|
|
119
|
-
// const loadImages = async (images) => {
|
|
120
|
-
// for await (const item of images) {
|
|
121
|
-
// await request(item);
|
|
122
|
-
// count++;
|
|
123
|
-
// }
|
|
124
|
-
// }
|
|
125
|
-
* @return {*}
|
|
126
|
-
*/
|
|
127
|
-
declare function asyncForEach(array: any[], callback: Function): Promise<void>;
|
|
128
|
-
|
|
129
|
-
declare const array_arrayEach: typeof arrayEach;
|
|
130
|
-
declare const array_arrayEachAsync: typeof arrayEachAsync;
|
|
131
|
-
declare const array_arrayInsertBefore: typeof arrayInsertBefore;
|
|
132
|
-
declare const array_arrayLike: typeof arrayLike;
|
|
133
|
-
declare const array_arrayRemove: typeof arrayRemove;
|
|
134
|
-
declare const array_asyncForEach: typeof asyncForEach;
|
|
135
|
-
declare const array_deepTraversal: typeof deepTraversal;
|
|
136
|
-
declare const array_getTreeIds: typeof getTreeIds;
|
|
137
|
-
declare namespace array {
|
|
138
|
-
export { array_arrayEach as arrayEach, array_arrayEachAsync as arrayEachAsync, array_arrayInsertBefore as arrayInsertBefore, array_arrayLike as arrayLike, array_arrayRemove as arrayRemove, array_asyncForEach as asyncForEach, array_deepTraversal as deepTraversal, array_getTreeIds as getTreeIds };
|
|
139
|
-
}
|
|
140
80
|
|
|
141
81
|
/**
|
|
142
82
|
* 复制文本
|
|
@@ -144,11 +84,6 @@ declare namespace array {
|
|
|
144
84
|
*/
|
|
145
85
|
declare const copyText: (text: string) => void;
|
|
146
86
|
|
|
147
|
-
declare const clipboard_copyText: typeof copyText;
|
|
148
|
-
declare namespace clipboard {
|
|
149
|
-
export { clipboard_copyText as copyText };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
87
|
/**
|
|
153
88
|
* 获取cookie
|
|
154
89
|
* @param {string} name
|
|
@@ -168,13 +103,6 @@ declare const cookieSet: (name: string, value: string, maxAge?: number | Date) =
|
|
|
168
103
|
*/
|
|
169
104
|
declare const cookieDel: (name: string) => void;
|
|
170
105
|
|
|
171
|
-
declare const cookie_cookieDel: typeof cookieDel;
|
|
172
|
-
declare const cookie_cookieGet: typeof cookieGet;
|
|
173
|
-
declare const cookie_cookieSet: typeof cookieSet;
|
|
174
|
-
declare namespace cookie {
|
|
175
|
-
export { cookie_cookieDel as cookieDel, cookie_cookieGet as cookieGet, cookie_cookieSet as cookieSet };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
106
|
/**
|
|
179
107
|
* 格式化为日期对象(带自定义格式化模板)
|
|
180
108
|
* @param {DateValue} value 可以是数值、字符串或 Date 对象
|
|
@@ -210,13 +138,6 @@ declare function calculateDate(strDate: string, n: number, sep?: string): string
|
|
|
210
138
|
*/
|
|
211
139
|
declare function calculateDateTime(n: number, dateSep?: string, timeSep?: string): string;
|
|
212
140
|
|
|
213
|
-
declare const date_calculateDate: typeof calculateDate;
|
|
214
|
-
declare const date_calculateDateTime: typeof calculateDateTime;
|
|
215
|
-
declare const date_formatDate: typeof formatDate;
|
|
216
|
-
declare namespace date {
|
|
217
|
-
export { date_calculateDate as calculateDate, date_calculateDateTime as calculateDateTime, date_formatDate as formatDate };
|
|
218
|
-
}
|
|
219
|
-
|
|
220
141
|
type EasingName = 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | string;
|
|
221
142
|
|
|
222
143
|
interface Style {
|
|
@@ -270,18 +191,14 @@ declare function smoothScroll(options?: Partial<SmoothScrollOptions>): Promise<v
|
|
|
270
191
|
type ReadyCallback = () => void;
|
|
271
192
|
declare function isDomReady(): boolean;
|
|
272
193
|
declare function onDomReady(callback: ReadyCallback): void;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
declare
|
|
281
|
-
declare const dom_smoothScroll: typeof smoothScroll;
|
|
282
|
-
declare namespace dom {
|
|
283
|
-
export { dom_addClass as addClass, dom_getStyle as getStyle, dom_hasClass as hasClass, dom_isDomReady as isDomReady, dom_onDomReady as onDomReady, dom_removeClass as removeClass, dom_setStyle as setStyle, dom_smoothScroll as smoothScroll };
|
|
284
|
-
}
|
|
194
|
+
/**
|
|
195
|
+
* 获取元素样式属性的计算值
|
|
196
|
+
* @param {HTMLElement} el
|
|
197
|
+
* @param {string} property
|
|
198
|
+
* @param {boolean} reNumber
|
|
199
|
+
* @return {string|number}
|
|
200
|
+
*/
|
|
201
|
+
declare function getComputedCssVal(el: HTMLElement, property: string, reNumber?: boolean): string | number;
|
|
285
202
|
|
|
286
203
|
interface Params<T = string | number> {
|
|
287
204
|
[key: string]: T | Array<T>;
|
|
@@ -305,16 +222,6 @@ type Replacer = (value: LooseParamValue) => string | null;
|
|
|
305
222
|
*/
|
|
306
223
|
declare const qsStringify: (query: LooseParams, replacer?: Replacer) => string;
|
|
307
224
|
|
|
308
|
-
type qs_LooseParamValue = LooseParamValue;
|
|
309
|
-
type qs_LooseParams<T = LooseParamValue> = LooseParams<T>;
|
|
310
|
-
type qs_Params<T = string | number> = Params<T>;
|
|
311
|
-
type qs_Replacer = Replacer;
|
|
312
|
-
declare const qs_qsParse: typeof qsParse;
|
|
313
|
-
declare const qs_qsStringify: typeof qsStringify;
|
|
314
|
-
declare namespace qs {
|
|
315
|
-
export { type qs_LooseParamValue as LooseParamValue, type qs_LooseParams as LooseParams, type qs_Params as Params, type qs_Replacer as Replacer, qs_qsParse as qsParse, qs_qsStringify as qsStringify };
|
|
316
|
-
}
|
|
317
|
-
|
|
318
225
|
/**
|
|
319
226
|
* 通过打开新窗口的方式下载
|
|
320
227
|
* @param {string} url
|
|
@@ -343,14 +250,6 @@ type FileType = 'json' | 'csv' | 'xls' | 'xlsx';
|
|
|
343
250
|
*/
|
|
344
251
|
declare const downloadData: (data: AnyObject | AnyObject[], fileType: FileType, filename: string, headers?: string[]) => void;
|
|
345
252
|
|
|
346
|
-
declare const download_downloadBlob: typeof downloadBlob;
|
|
347
|
-
declare const download_downloadData: typeof downloadData;
|
|
348
|
-
declare const download_downloadHref: typeof downloadHref;
|
|
349
|
-
declare const download_downloadURL: typeof downloadURL;
|
|
350
|
-
declare namespace download {
|
|
351
|
-
export { download_downloadBlob as downloadBlob, download_downloadData as downloadData, download_downloadHref as downloadHref, download_downloadURL as downloadURL };
|
|
352
|
-
}
|
|
353
|
-
|
|
354
253
|
/**
|
|
355
254
|
* 判断对象是否为纯对象
|
|
356
255
|
* @param {object} obj
|
|
@@ -427,21 +326,6 @@ declare function objectGet(obj: AnyObject, path: string, strict?: boolean): {
|
|
|
427
326
|
*/
|
|
428
327
|
declare function cloneDeep(obj: Object, map?: WeakMap<WeakKey, any>): Object;
|
|
429
328
|
|
|
430
|
-
declare const object_cloneDeep: typeof cloneDeep;
|
|
431
|
-
declare const object_isPlainObject: typeof isPlainObject;
|
|
432
|
-
declare const object_objectAssign: typeof objectAssign;
|
|
433
|
-
declare const object_objectEach: typeof objectEach;
|
|
434
|
-
declare const object_objectEachAsync: typeof objectEachAsync;
|
|
435
|
-
declare const object_objectFill: typeof objectFill;
|
|
436
|
-
declare const object_objectGet: typeof objectGet;
|
|
437
|
-
declare const object_objectHas: typeof objectHas;
|
|
438
|
-
declare const object_objectMap: typeof objectMap;
|
|
439
|
-
declare const object_objectOmit: typeof objectOmit;
|
|
440
|
-
declare const object_objectPick: typeof objectPick;
|
|
441
|
-
declare namespace object {
|
|
442
|
-
export { object_cloneDeep as cloneDeep, object_isPlainObject as isPlainObject, object_objectAssign as objectAssign, object_objectEach as objectEach, object_objectEachAsync as objectEachAsync, object_objectFill as objectFill, object_objectGet as objectGet, object_objectHas as objectHas, object_objectMap as objectMap, objectAssign as objectMerge, object_objectOmit as objectOmit, object_objectPick as objectPick };
|
|
443
|
-
}
|
|
444
|
-
|
|
445
329
|
/**
|
|
446
330
|
* 标准化路径
|
|
447
331
|
* @param {string} path
|
|
@@ -456,12 +340,6 @@ declare const pathNormalize: (path: string) => string;
|
|
|
456
340
|
*/
|
|
457
341
|
declare const pathJoin: (from: string, ...to: string[]) => string;
|
|
458
342
|
|
|
459
|
-
declare const path_pathJoin: typeof pathJoin;
|
|
460
|
-
declare const path_pathNormalize: typeof pathNormalize;
|
|
461
|
-
declare namespace path {
|
|
462
|
-
export { path_pathJoin as pathJoin, path_pathNormalize as pathNormalize };
|
|
463
|
-
}
|
|
464
|
-
|
|
465
343
|
/**
|
|
466
344
|
* 将字符串转换为驼峰格式
|
|
467
345
|
* @param {string} string
|
|
@@ -521,19 +399,14 @@ declare const stringEscapeHtml: (html: string) => string;
|
|
|
521
399
|
* @returns {string}
|
|
522
400
|
*/
|
|
523
401
|
declare const stringFill: (length: number, value?: string) => string;
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
declare
|
|
532
|
-
declare const string_stringFormat: typeof stringFormat;
|
|
533
|
-
declare const string_stringKebabCase: typeof stringKebabCase;
|
|
534
|
-
declare namespace string {
|
|
535
|
-
export { string_STRING_ARABIC_NUMERALS as STRING_ARABIC_NUMERALS, string_STRING_LOWERCASE_ALPHA as STRING_LOWERCASE_ALPHA, string_STRING_UPPERCASE_ALPHA as STRING_UPPERCASE_ALPHA, string_stringAssign as stringAssign, string_stringCamelCase as stringCamelCase, string_stringEscapeHtml as stringEscapeHtml, string_stringFill as stringFill, string_stringFormat as stringFormat, string_stringKebabCase as stringKebabCase };
|
|
536
|
-
}
|
|
402
|
+
/**
|
|
403
|
+
* 字符串的像素宽度
|
|
404
|
+
* @param {string} str 目标字符串
|
|
405
|
+
* @param {number} fontSize 字符串字体大小
|
|
406
|
+
* @param {boolean} isRemoveDom 计算后是否移除中间dom元素
|
|
407
|
+
* @return {*}
|
|
408
|
+
*/
|
|
409
|
+
declare function getStrWidthPx(str: string, fontSize?: number, isRemoveDom?: boolean): number;
|
|
537
410
|
|
|
538
411
|
interface Url {
|
|
539
412
|
protocol: string;
|
|
@@ -578,14 +451,6 @@ declare const urlSetParams: (url: string, setter: AnyObject) => string;
|
|
|
578
451
|
*/
|
|
579
452
|
declare const urlDelParams: (url: string, removeKeys: string[]) => string;
|
|
580
453
|
|
|
581
|
-
declare const url_urlDelParams: typeof urlDelParams;
|
|
582
|
-
declare const url_urlParse: typeof urlParse;
|
|
583
|
-
declare const url_urlSetParams: typeof urlSetParams;
|
|
584
|
-
declare const url_urlStringify: typeof urlStringify;
|
|
585
|
-
declare namespace url {
|
|
586
|
-
export { url_urlDelParams as urlDelParams, url_urlParse as urlParse, url_urlSetParams as urlSetParams, url_urlStringify as urlStringify };
|
|
587
|
-
}
|
|
588
|
-
|
|
589
454
|
/**
|
|
590
455
|
* 等待一段时间
|
|
591
456
|
* @param {number} timeout 等待时间,单位毫秒
|
|
@@ -603,12 +468,6 @@ declare function wait(timeout?: number): Promise<void>;
|
|
|
603
468
|
*/
|
|
604
469
|
declare function asyncMap<T, R>(list: Array<T>, mapper: (val: T, idx: number, list: Array<T>) => Promise<R>, concurrency?: number): Promise<R[]>;
|
|
605
470
|
|
|
606
|
-
declare const async_asyncMap: typeof asyncMap;
|
|
607
|
-
declare const async_wait: typeof wait;
|
|
608
|
-
declare namespace async {
|
|
609
|
-
export { async_asyncMap as asyncMap, async_wait as wait };
|
|
610
|
-
}
|
|
611
|
-
|
|
612
471
|
/**
|
|
613
472
|
* 选择本地文件
|
|
614
473
|
* @param {function} changeCb 选择文件回调
|
|
@@ -618,11 +477,6 @@ declare function chooseLocalFile({ accept }: {
|
|
|
618
477
|
accept: any;
|
|
619
478
|
}, changeCb: (FileList: any) => any): HTMLInputElement;
|
|
620
479
|
|
|
621
|
-
declare const file_chooseLocalFile: typeof chooseLocalFile;
|
|
622
|
-
declare namespace file {
|
|
623
|
-
export { file_chooseLocalFile as chooseLocalFile };
|
|
624
|
-
}
|
|
625
|
-
|
|
626
480
|
interface ICanvasWM {
|
|
627
481
|
container: HTMLElement;
|
|
628
482
|
width: string;
|
|
@@ -641,4 +495,126 @@ interface ICanvasWM {
|
|
|
641
495
|
*/
|
|
642
496
|
declare const genCanvasWM: (canvasWM: ICanvasWM) => void;
|
|
643
497
|
|
|
644
|
-
|
|
498
|
+
interface DebounceFunc<F extends AnyFunc> {
|
|
499
|
+
(...args: Parameters<F>): void;
|
|
500
|
+
cancel: () => void;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* 防抖函数
|
|
504
|
+
* 当函数被连续调用时,该函数并不执行,只有当其全部停止调用超过一定时间后才执行1次。
|
|
505
|
+
* 例如:上电梯的时候,大家陆陆续续进来,电梯的门不会关上,只有当一段时间都没有人上来,电梯才会关门。
|
|
506
|
+
* @param {F} func
|
|
507
|
+
* @param {number} wait
|
|
508
|
+
* @returns {DebounceFunc<F>}
|
|
509
|
+
*/
|
|
510
|
+
declare const debounce: <F extends AnyFunc>(func: F, wait?: number) => DebounceFunc<F>;
|
|
511
|
+
interface ThrottleFunc<F extends AnyFunc> {
|
|
512
|
+
(...args: Parameters<F>): void;
|
|
513
|
+
cancel: () => void;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* 节流函数
|
|
517
|
+
* 节流就是节约流量,将连续触发的事件稀释成预设评率。 比如每间隔1秒执行一次函数,无论这期间触发多少次事件。
|
|
518
|
+
* 这有点像公交车,无论在站点等车的人多不多,公交车只会按时来一班,不会来一个人就来一辆公交车。
|
|
519
|
+
* @param {F} func
|
|
520
|
+
* @param {number} wait
|
|
521
|
+
* @param {boolean} immediate
|
|
522
|
+
* @returns {ThrottleFunc<F>}
|
|
523
|
+
*/
|
|
524
|
+
declare const throttle: <F extends AnyFunc>(func: F, wait: number, immediate?: boolean) => ThrottleFunc<F>;
|
|
525
|
+
interface OnceFunc<F extends AnyFunc> {
|
|
526
|
+
(...args: Parameters<F>): ReturnType<F>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* 单次函数
|
|
530
|
+
* @param {AnyFunc} func
|
|
531
|
+
* @returns {AnyFunc}
|
|
532
|
+
*/
|
|
533
|
+
declare const once: <F extends AnyFunc = AnyFunc>(func: F) => OnceFunc<F>;
|
|
534
|
+
/**
|
|
535
|
+
* 设置全局变量
|
|
536
|
+
* @param {string | number | symbol} key
|
|
537
|
+
* @param val
|
|
538
|
+
*/
|
|
539
|
+
declare function setGlobal(key: string | number | symbol, val?: any): void;
|
|
540
|
+
/**
|
|
541
|
+
* 设置全局变量
|
|
542
|
+
* @param {string | number | symbol} key
|
|
543
|
+
* @param val
|
|
544
|
+
*/
|
|
545
|
+
declare function getGlobal<T>(key: string | number | symbol): T | void;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* 随机整数
|
|
549
|
+
* @param {number} min
|
|
550
|
+
* @param {number} max
|
|
551
|
+
* @returns {number}
|
|
552
|
+
*/
|
|
553
|
+
declare const randomNumber: (min: number, max: number) => number;
|
|
554
|
+
declare const STRING_POOL = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
555
|
+
interface RandomString {
|
|
556
|
+
(length: number, pool: string): string;
|
|
557
|
+
(length: number): string;
|
|
558
|
+
(pool: string): string;
|
|
559
|
+
(): string;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* 随机字符串
|
|
563
|
+
* @param {number | string} length
|
|
564
|
+
* @param {string} pool
|
|
565
|
+
* @returns {string}
|
|
566
|
+
*/
|
|
567
|
+
declare const randomString: RandomString;
|
|
568
|
+
/**
|
|
569
|
+
* 优先浏览器原生能力获取 UUID v4
|
|
570
|
+
* @returns {string}
|
|
571
|
+
*/
|
|
572
|
+
declare function randomUuid(): string;
|
|
573
|
+
|
|
574
|
+
declare const HEX_POOL = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
575
|
+
/**
|
|
576
|
+
* 将十进制转换成任意进制
|
|
577
|
+
* @param {number | string} decimal 十进制数值或字符串,可以是任意长度,会使用大数进行计算
|
|
578
|
+
* @param {string} [hexPool] 进制池,默认 62 进制
|
|
579
|
+
* @returns {string}
|
|
580
|
+
*/
|
|
581
|
+
declare const numberToHex: (decimal: number | string, hexPool?: string) => string;
|
|
582
|
+
/**
|
|
583
|
+
* 缩写
|
|
584
|
+
* @param {number | string} num
|
|
585
|
+
* @param {Array<string>} units
|
|
586
|
+
* @param {number} ratio
|
|
587
|
+
* @param {number} exponent
|
|
588
|
+
* @returns {string}
|
|
589
|
+
*/
|
|
590
|
+
declare const numberAbbr: (num: number | string, units: Array<string>, ratio?: number, exponent?: number) => string;
|
|
591
|
+
/**
|
|
592
|
+
* 将数字格式化成千位分隔符显示的字符串
|
|
593
|
+
* @param {number} val 数字
|
|
594
|
+
* @param {'int' | 'float'} type 展示分段显示的类型 int:整型 | float:浮点型
|
|
595
|
+
* @return {string}
|
|
596
|
+
*/
|
|
597
|
+
declare function formatNumber(val: number, type?: string): string;
|
|
598
|
+
|
|
599
|
+
declare const UNIQUE_NUMBER_SAFE_LENGTH = 18;
|
|
600
|
+
/**
|
|
601
|
+
* 生成唯一不重复数值
|
|
602
|
+
* @param {number} length
|
|
603
|
+
* @returns {string}
|
|
604
|
+
*/
|
|
605
|
+
declare const uniqueNumber: (length?: number) => string;
|
|
606
|
+
interface UniqueString {
|
|
607
|
+
(length: number, pool: string): string;
|
|
608
|
+
(length: number): string;
|
|
609
|
+
(pool: string): string;
|
|
610
|
+
(): string;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* 生成唯一不重复字符串
|
|
614
|
+
* @param {number | string} length
|
|
615
|
+
* @param {string} pool
|
|
616
|
+
* @returns {string}
|
|
617
|
+
*/
|
|
618
|
+
declare const uniqueString: UniqueString;
|
|
619
|
+
|
|
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 };
|