@whitesev/utils 1.0.4 → 1.0.6
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/index.amd.js +5885 -1817
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +5533 -1467
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +5531 -1467
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +5886 -1817
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +5897 -1826
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +5889 -1817
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Dictionary.d.ts +82 -0
- package/dist/src/Hooks.d.ts +11 -0
- package/dist/src/Httpx.d.ts +1201 -0
- package/dist/src/LockFunction.d.ts +31 -0
- package/dist/src/Log.d.ts +96 -0
- package/dist/src/Progress.d.ts +37 -0
- package/dist/src/UtilsGMMenu.d.ts +156 -0
- package/dist/src/index.d.ts +20 -27
- package/dist/src/indexedDB.d.ts +73 -0
- package/dist/src/tryCatch.d.ts +31 -0
- package/package.json +36 -37
- package/rollup.config.js +0 -3
- package/src/Dictionary.ts +152 -0
- package/src/{Hooks/Hooks.js → Hooks.ts} +31 -17
- package/src/{Httpx/index.d.ts → Httpx.ts} +837 -46
- package/src/LockFunction.ts +62 -0
- package/src/Log.ts +281 -0
- package/src/Progress.ts +143 -0
- package/src/UtilsGMMenu.ts +681 -0
- package/src/index.ts +17 -29
- package/src/indexedDB.ts +421 -0
- package/src/tryCatch.ts +107 -0
- package/tsconfig.json +1 -1
- package/dist/src/Dictionary/Dictionary.d.ts +0 -85
- package/dist/src/Hooks/Hooks.d.ts +0 -5
- package/dist/src/Httpx/Httpx.d.ts +0 -50
- package/dist/src/LockFunction/LockFunction.d.ts +0 -16
- package/dist/src/Log/Log.d.ts +0 -66
- package/dist/src/Progress/Progress.d.ts +0 -6
- package/dist/src/UtilsGMMenu/UtilsGMMenu.d.ts +0 -119
- package/dist/src/indexedDB/indexedDB.d.ts +0 -165
- package/dist/src/tryCatch/tryCatch.d.ts +0 -31
- package/src/Dictionary/Dictionary.js +0 -157
- package/src/Dictionary/index.d.ts +0 -52
- package/src/Hooks/index.d.ts +0 -16
- package/src/Httpx/Httpx.js +0 -747
- package/src/LockFunction/LockFunction.js +0 -35
- package/src/LockFunction/index.d.ts +0 -47
- package/src/Log/Log.js +0 -256
- package/src/Log/index.d.ts +0 -91
- package/src/Progress/Progress.js +0 -98
- package/src/Progress/index.d.ts +0 -30
- package/src/UtilsGMMenu/UtilsGMMenu.js +0 -464
- package/src/UtilsGMMenu/index.d.ts +0 -224
- package/src/indexedDB/index.d.ts +0 -128
- package/src/indexedDB/indexedDB.js +0 -355
- package/src/tryCatch/index.d.ts +0 -6
- package/src/tryCatch/tryCatch.js +0 -100
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
export class UtilsDictionary {
|
|
2
|
-
items: {};
|
|
3
|
-
/**
|
|
4
|
-
* 检查是否有某一个键
|
|
5
|
-
* @param {string} key 键
|
|
6
|
-
* @returns {boolean}
|
|
7
|
-
*/
|
|
8
|
-
has(key: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* 检查已有的键中是否以xx开头
|
|
11
|
-
* @param {string} key 需要匹配的键
|
|
12
|
-
* @returns {boolean}
|
|
13
|
-
*/
|
|
14
|
-
startsWith(key: string): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* 获取以xx开头的键的值
|
|
17
|
-
* @param {string} key 需要匹配的键
|
|
18
|
-
* @returns {any}
|
|
19
|
-
*/
|
|
20
|
-
getStartsWith(key: string): any;
|
|
21
|
-
/**
|
|
22
|
-
* 为字典添加某一个值
|
|
23
|
-
* @param {string} key 键
|
|
24
|
-
* @param {any} val 值,默认为""
|
|
25
|
-
*/
|
|
26
|
-
set(key: string, val?: any): void;
|
|
27
|
-
/**
|
|
28
|
-
* 删除某一个键
|
|
29
|
-
* @param {string} key 键
|
|
30
|
-
* @returns {boolean}
|
|
31
|
-
*/
|
|
32
|
-
delete(key: string): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* 获取某个键的值
|
|
35
|
-
* @param {string} key 键
|
|
36
|
-
* @returns {any}
|
|
37
|
-
*/
|
|
38
|
-
get(key: string): any;
|
|
39
|
-
/**
|
|
40
|
-
* 返回字典中的所有值
|
|
41
|
-
* @returns {any[]}
|
|
42
|
-
*/
|
|
43
|
-
values(): any[];
|
|
44
|
-
/**
|
|
45
|
-
* 清空字典
|
|
46
|
-
*/
|
|
47
|
-
clear(): void;
|
|
48
|
-
/**
|
|
49
|
-
* 获取字典的长度
|
|
50
|
-
* @returns {number}
|
|
51
|
-
*/
|
|
52
|
-
size(): number;
|
|
53
|
-
/**
|
|
54
|
-
* 获取字典所有的键
|
|
55
|
-
*/
|
|
56
|
-
keys(): string[];
|
|
57
|
-
/**
|
|
58
|
-
* 返回字典本身
|
|
59
|
-
* @returns {object}
|
|
60
|
-
*/
|
|
61
|
-
getItems(): object;
|
|
62
|
-
/**
|
|
63
|
-
* 合并另一个字典
|
|
64
|
-
* @param {object} data 需要合并的字典
|
|
65
|
-
*/
|
|
66
|
-
concat(data: object): void;
|
|
67
|
-
forEach(callbackfn: any): void;
|
|
68
|
-
/**
|
|
69
|
-
* 获取字典的长度,同this.size
|
|
70
|
-
* @returns {number}
|
|
71
|
-
*/
|
|
72
|
-
get length(): number;
|
|
73
|
-
/**
|
|
74
|
-
* 迭代器
|
|
75
|
-
*/
|
|
76
|
-
get entries(): () => Generator<any[], void, unknown>;
|
|
77
|
-
/**
|
|
78
|
-
* 是否可遍历
|
|
79
|
-
*/
|
|
80
|
-
get [Symbol.iterator](): () => Generator<any[], void, unknown>;
|
|
81
|
-
/**
|
|
82
|
-
* .toString()和.toLocaleString()输出的字符串
|
|
83
|
-
*/
|
|
84
|
-
get [Symbol.toStringTag](): string;
|
|
85
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export function Httpx(__xmlHttpRequest__: any): void;
|
|
2
|
-
export class Httpx {
|
|
3
|
-
constructor(__xmlHttpRequest__: any);
|
|
4
|
-
/**
|
|
5
|
-
* 覆盖当前配置
|
|
6
|
-
* @param {HttpxDetailsConfig} details
|
|
7
|
-
*/
|
|
8
|
-
config: (details?: HttpxDetailsConfig) => void;
|
|
9
|
-
/**
|
|
10
|
-
* 修改xmlHttpRequest
|
|
11
|
-
* @param {Function} httpRequest 网络请求函数
|
|
12
|
-
*/
|
|
13
|
-
setXMLHttpRequest: (httpRequest: Function) => void;
|
|
14
|
-
/**
|
|
15
|
-
* GET 请求
|
|
16
|
-
* @param {...HttpxDetails|string} args
|
|
17
|
-
* @returns {Promise< HttpxAsyncResult >}
|
|
18
|
-
*/
|
|
19
|
-
get: (...args: (HttpxDetails | string)[]) => Promise<HttpxAsyncResult<any>>;
|
|
20
|
-
/**
|
|
21
|
-
* POST 请求
|
|
22
|
-
* @param {...HttpxDetails|string} args
|
|
23
|
-
* @returns {Promise< HttpxAsyncResult >}
|
|
24
|
-
*/
|
|
25
|
-
post: (...args: (HttpxDetails | string)[]) => Promise<HttpxAsyncResult<any>>;
|
|
26
|
-
/**
|
|
27
|
-
* HEAD 请求
|
|
28
|
-
* @param {...HttpxDetails|string} args
|
|
29
|
-
* @returns {Promise< HttpxAsyncResult >}
|
|
30
|
-
*/
|
|
31
|
-
head: (...args: (HttpxDetails | string)[]) => Promise<HttpxAsyncResult<any>>;
|
|
32
|
-
/**
|
|
33
|
-
* OPTIONS 请求
|
|
34
|
-
* @param {...HttpxDetails|string} args
|
|
35
|
-
* @returns {Promise< HttpxAsyncResult >}
|
|
36
|
-
*/
|
|
37
|
-
options: (...args: (HttpxDetails | string)[]) => Promise<HttpxAsyncResult<any>>;
|
|
38
|
-
/**
|
|
39
|
-
* DELETE 请求
|
|
40
|
-
* @param {...HttpxDetails|string} args
|
|
41
|
-
* @returns {Promise< HttpxAsyncResult >}
|
|
42
|
-
*/
|
|
43
|
-
delete: (...args: (HttpxDetails | string)[]) => Promise<HttpxAsyncResult<any>>;
|
|
44
|
-
/**
|
|
45
|
-
* PUT 请求
|
|
46
|
-
* @param {...HttpxDetails|string} args
|
|
47
|
-
* @returns {Promise< HttpxAsyncResult >}
|
|
48
|
-
*/
|
|
49
|
-
put: (...args: (HttpxDetails | string)[]) => Promise<HttpxAsyncResult<any>>;
|
|
50
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function LockFunction(callback: any, context: any, delayTime?: number): void;
|
|
2
|
-
export class LockFunction {
|
|
3
|
-
constructor(callback: any, context: any, delayTime?: number);
|
|
4
|
-
/**
|
|
5
|
-
* 锁
|
|
6
|
-
*/
|
|
7
|
-
lock: () => void;
|
|
8
|
-
/**
|
|
9
|
-
* 解锁
|
|
10
|
-
*/
|
|
11
|
-
unlock: () => void;
|
|
12
|
-
/**
|
|
13
|
-
* 执行
|
|
14
|
-
*/
|
|
15
|
-
run: (...args: any[]) => Promise<void>;
|
|
16
|
-
}
|
package/dist/src/Log/Log.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export function Log(_GM_info_?: {
|
|
2
|
-
script: {
|
|
3
|
-
name: string;
|
|
4
|
-
};
|
|
5
|
-
}, console?: Console): void;
|
|
6
|
-
export class Log {
|
|
7
|
-
constructor(_GM_info_?: {
|
|
8
|
-
script: {
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
}, console?: Console);
|
|
12
|
-
/**
|
|
13
|
-
* 前面的TAG标志
|
|
14
|
-
*/
|
|
15
|
-
tag: string;
|
|
16
|
-
/**
|
|
17
|
-
* 控制台-普通输出
|
|
18
|
-
* @param {any} msg 需要输出的内容,如果想输出多个,修改成数组,且数组内的长度最大值为4个
|
|
19
|
-
* @param {string|undefined} color 输出的颜色
|
|
20
|
-
* @param {string|undefined} otherStyle 其它CSS
|
|
21
|
-
*/
|
|
22
|
-
info: (msg: any, color: string | undefined, otherStyle: string | undefined) => void;
|
|
23
|
-
/**
|
|
24
|
-
* 控制台-警告输出
|
|
25
|
-
* @param {any} msg 需要输出的内容,如果想输出多个,修改成数组,且数组内的长度最大值为4个
|
|
26
|
-
* @param {string|undefined} color 输出的颜色
|
|
27
|
-
* @param {string|undefined} otherStyle 其它CSS
|
|
28
|
-
*/
|
|
29
|
-
warn: (msg: any, color?: string | undefined, otherStyle?: string | undefined) => void;
|
|
30
|
-
/**
|
|
31
|
-
* 控制台-错误输出
|
|
32
|
-
* @param {any} msg 需要输出的内容,如果想输出多个,修改成数组,且数组内的长度最大值为4个
|
|
33
|
-
* @param {string|undefined} color 输出的颜色
|
|
34
|
-
* @param {string|undefined} otherStyle 其它CSS
|
|
35
|
-
*/
|
|
36
|
-
error: (msg: any, color: string | undefined, otherStyle: string | undefined) => void;
|
|
37
|
-
/**
|
|
38
|
-
* 控制台-成功输出
|
|
39
|
-
* @param {any} msg 需要输出的内容,如果想输出多个,修改成数组,且数组内的长度最大值为4个
|
|
40
|
-
* @param {string|undefined} color 输出的颜色
|
|
41
|
-
* @param {string|undefined} otherStyle 其它CSS
|
|
42
|
-
*/
|
|
43
|
-
success: (msg: any, color: string | undefined, otherStyle: string | undefined) => void;
|
|
44
|
-
/**
|
|
45
|
-
* 控制台-输出表格
|
|
46
|
-
* @param {object[]} msg
|
|
47
|
-
* @param {string|undefined} color 输出的颜色
|
|
48
|
-
* @param {string|undefined} otherStyle 其它CSS
|
|
49
|
-
* @example
|
|
50
|
-
* log.table([{"名字":"example","值":"123"},{"名字":"example2","值":"345"}])
|
|
51
|
-
*/
|
|
52
|
-
table: (msg: object[], color?: string | undefined, otherStyle?: string | undefined) => void;
|
|
53
|
-
/**
|
|
54
|
-
* 配置Log对象的颜色
|
|
55
|
-
* @param {UtilsLogOptions} paramDetails 配置信息
|
|
56
|
-
*/
|
|
57
|
-
config: (paramDetails: UtilsLogOptions) => void;
|
|
58
|
-
/**
|
|
59
|
-
* 禁用输出
|
|
60
|
-
*/
|
|
61
|
-
disable: () => void;
|
|
62
|
-
/**
|
|
63
|
-
* 恢复输出
|
|
64
|
-
*/
|
|
65
|
-
recovery: () => void;
|
|
66
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {UtilsGMMenuConstructorOptions} details
|
|
4
|
-
*/
|
|
5
|
-
export function GMMenu(details: UtilsGMMenuConstructorOptions): void;
|
|
6
|
-
export class GMMenu {
|
|
7
|
-
constructor(details: UtilsGMMenuConstructorOptions);
|
|
8
|
-
/**
|
|
9
|
-
* 新增菜单数据
|
|
10
|
-
* @param {UtilsGMMenuOption[]|UtilsGMMenuOption} paramData
|
|
11
|
-
*/
|
|
12
|
-
add: (paramData: UtilsGMMenuOption[] | UtilsGMMenuOption) => void;
|
|
13
|
-
/**
|
|
14
|
-
* 更新菜单数据
|
|
15
|
-
* @param { ?UtilsGMMenuOption[]|UtilsGMMenuOption } options 数据
|
|
16
|
-
*/
|
|
17
|
-
update: (options: (UtilsGMMenuOption[] | UtilsGMMenuOption) | null) => void;
|
|
18
|
-
/**
|
|
19
|
-
* 卸载菜单
|
|
20
|
-
* @param {number} menuId 已注册的菜单id
|
|
21
|
-
*/
|
|
22
|
-
delete: (menuId: number) => void;
|
|
23
|
-
/**
|
|
24
|
-
* 根据键值获取enable值
|
|
25
|
-
* @param {string} menuKey 菜单-键key
|
|
26
|
-
* @returns {boolean}
|
|
27
|
-
*/
|
|
28
|
-
get: (menuKey: string) => boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 根据键值获取enable值
|
|
31
|
-
* @param {string} menuKey 菜单-键key
|
|
32
|
-
* @returns {boolean}
|
|
33
|
-
*/
|
|
34
|
-
getEnable: (menuKey: string) => boolean;
|
|
35
|
-
/**
|
|
36
|
-
* 根据键值获取text值
|
|
37
|
-
* @param {string} menuKey 菜单-键key
|
|
38
|
-
* @returns {string}
|
|
39
|
-
*/
|
|
40
|
-
getText: (menuKey: string) => string;
|
|
41
|
-
/**
|
|
42
|
-
* 根据键值获取showText函数的值
|
|
43
|
-
* @param {string} menuKey 菜单-键key
|
|
44
|
-
* @returns {string}
|
|
45
|
-
*/
|
|
46
|
-
getShowTextValue: (menuKey: string) => string;
|
|
47
|
-
/**
|
|
48
|
-
* 获取当前已注册菜单的id
|
|
49
|
-
* @param {string} menuKey
|
|
50
|
-
* @returns {?number}
|
|
51
|
-
*/
|
|
52
|
-
getMenuId: (menuKey: string) => number | null;
|
|
53
|
-
/**
|
|
54
|
-
* 根据键值获取accessKey值
|
|
55
|
-
* @param {string} menuKey 菜单-键key
|
|
56
|
-
* @returns {?string}
|
|
57
|
-
*/
|
|
58
|
-
getAccessKey: (menuKey: string) => string | null;
|
|
59
|
-
/**
|
|
60
|
-
* 根据键值获取autoClose值
|
|
61
|
-
* @param {string} menuKey 菜单-键key
|
|
62
|
-
* @returns {?boolean}
|
|
63
|
-
*/
|
|
64
|
-
getAutoClose: (menuKey: string) => boolean | null;
|
|
65
|
-
/**
|
|
66
|
-
* 根据键值获取autoReload值
|
|
67
|
-
* @param {string} menuKey 菜单-键key
|
|
68
|
-
* @returns {boolean}
|
|
69
|
-
*/
|
|
70
|
-
getAutoReload: (menuKey: string) => boolean;
|
|
71
|
-
/**
|
|
72
|
-
* 根据键值获取callback函数
|
|
73
|
-
* @param {string} menuKey 菜单-键key
|
|
74
|
-
* @returns {?Function}
|
|
75
|
-
*/
|
|
76
|
-
getCallBack: (menuKey: string) => Function | null;
|
|
77
|
-
/**
|
|
78
|
-
* 获取当enable为true时默认显示在菜单中前面的emoji图标
|
|
79
|
-
* @returns {string}
|
|
80
|
-
*/
|
|
81
|
-
getEnableTrueEmoji: () => string;
|
|
82
|
-
/**
|
|
83
|
-
* 获取当enable为false时默认显示在菜单中前面的emoji图标
|
|
84
|
-
* @returns {string}
|
|
85
|
-
*/
|
|
86
|
-
getEnableFalseEmoji: () => string;
|
|
87
|
-
/**
|
|
88
|
-
* 获取本地存储的菜单外部的键名
|
|
89
|
-
* @param {string} keyName
|
|
90
|
-
*/
|
|
91
|
-
getLocalStorageKeyName: () => string;
|
|
92
|
-
/**
|
|
93
|
-
* 设置菜单的值
|
|
94
|
-
* @param {string} menuKey 菜单-键key
|
|
95
|
-
* @param {any} value 需要设置的值
|
|
96
|
-
*/
|
|
97
|
-
setValue: (menuKey: string, value: any) => void;
|
|
98
|
-
/**
|
|
99
|
-
* 设置菜单的值
|
|
100
|
-
* @param {string} menuKey 菜单-键key
|
|
101
|
-
* @param {boolean} value 需要设置的值
|
|
102
|
-
*/
|
|
103
|
-
setEnable: (menuKey: string, value: boolean) => void;
|
|
104
|
-
/**
|
|
105
|
-
* 设置当enable为true时默认显示在菜单中前面的emoji图标
|
|
106
|
-
* @param {string} emojiString
|
|
107
|
-
*/
|
|
108
|
-
setEnableTrueEmoji: (emojiString: string) => void;
|
|
109
|
-
/**
|
|
110
|
-
* 设置当enable为false时默认显示在菜单中前面的emoji图标
|
|
111
|
-
* @param {string} emojiString
|
|
112
|
-
*/
|
|
113
|
-
setEnableFalseEmoji: (emojiString: string) => void;
|
|
114
|
-
/**
|
|
115
|
-
* 设置本地存储的菜单外部的键名
|
|
116
|
-
* @param {string} keyName
|
|
117
|
-
*/
|
|
118
|
-
setLocalStorageKeyName: (keyName: string) => void;
|
|
119
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
export function indexedDB(dbName?: string, storeName?: string, dbVersion?: number): void;
|
|
2
|
-
export class indexedDB {
|
|
3
|
-
constructor(dbName?: string, storeName?: string, dbVersion?: number);
|
|
4
|
-
dbName: string;
|
|
5
|
-
slqVersion: string;
|
|
6
|
-
dbVersion: number;
|
|
7
|
-
storeName: string;
|
|
8
|
-
indexedDB: IDBFactory;
|
|
9
|
-
db: {};
|
|
10
|
-
store: any;
|
|
11
|
-
errorCode: {
|
|
12
|
-
success: {
|
|
13
|
-
code: number;
|
|
14
|
-
msg: string;
|
|
15
|
-
};
|
|
16
|
-
error: {
|
|
17
|
-
code: number;
|
|
18
|
-
msg: string;
|
|
19
|
-
};
|
|
20
|
-
open: {
|
|
21
|
-
code: number;
|
|
22
|
-
msg: string;
|
|
23
|
-
};
|
|
24
|
-
save: {
|
|
25
|
-
code: number;
|
|
26
|
-
msg: string;
|
|
27
|
-
};
|
|
28
|
-
get: {
|
|
29
|
-
code: number;
|
|
30
|
-
msg: string;
|
|
31
|
-
};
|
|
32
|
-
delete: {
|
|
33
|
-
code: number;
|
|
34
|
-
msg: string;
|
|
35
|
-
};
|
|
36
|
-
deleteAll: {
|
|
37
|
-
code: number;
|
|
38
|
-
msg: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* 创建 “表”
|
|
43
|
-
* @param {string} dbName 表名
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
createStore: (dbName: string) => any;
|
|
47
|
-
/**
|
|
48
|
-
* 打开数据库
|
|
49
|
-
* @param {function} callback 回调
|
|
50
|
-
* @param {string} dbName 数据库名
|
|
51
|
-
*/
|
|
52
|
-
open: (callback: Function, dbName: string) => void;
|
|
53
|
-
/**
|
|
54
|
-
* 保存数据到数据库
|
|
55
|
-
* @param {string} key 数据key
|
|
56
|
-
* @param {any} value 数据值
|
|
57
|
-
* @returns {Promise< {
|
|
58
|
-
* code: number,
|
|
59
|
-
* msg: string,
|
|
60
|
-
* success: boolean
|
|
61
|
-
* }>}
|
|
62
|
-
*/
|
|
63
|
-
save: (key: string, value: any) => Promise<{
|
|
64
|
-
code: number;
|
|
65
|
-
msg: string;
|
|
66
|
-
success: boolean;
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* 根据key获取值
|
|
70
|
-
* @param {string} key 数据key
|
|
71
|
-
* @returns {Promise< {
|
|
72
|
-
* code: number,
|
|
73
|
-
* msg: string,
|
|
74
|
-
* data: [...any],
|
|
75
|
-
* success: true
|
|
76
|
-
* }| {
|
|
77
|
-
* code: number,
|
|
78
|
-
* msg: string,
|
|
79
|
-
* error: Error,
|
|
80
|
-
* result: any,
|
|
81
|
-
* } >}
|
|
82
|
-
*/
|
|
83
|
-
get: (key: string) => Promise<{
|
|
84
|
-
code: number;
|
|
85
|
-
msg: string;
|
|
86
|
-
data: [...any];
|
|
87
|
-
success: true;
|
|
88
|
-
} | {
|
|
89
|
-
code: number;
|
|
90
|
-
msg: string;
|
|
91
|
-
error: Error;
|
|
92
|
-
result: any;
|
|
93
|
-
}>;
|
|
94
|
-
/**
|
|
95
|
-
* 正则获取数据
|
|
96
|
-
* @param {string} key 数据键
|
|
97
|
-
* @returns { Promise<{
|
|
98
|
-
* code: number,
|
|
99
|
-
* msg: string,
|
|
100
|
-
* data: [...any],
|
|
101
|
-
* success: true
|
|
102
|
-
* }|{
|
|
103
|
-
* code: number,
|
|
104
|
-
* msg: string,
|
|
105
|
-
* error: Error,
|
|
106
|
-
* result: any,
|
|
107
|
-
* }> }
|
|
108
|
-
*/
|
|
109
|
-
regexpGet: (key: string) => Promise<{
|
|
110
|
-
code: number;
|
|
111
|
-
msg: string;
|
|
112
|
-
data: [...any];
|
|
113
|
-
success: true;
|
|
114
|
-
} | {
|
|
115
|
-
code: number;
|
|
116
|
-
msg: string;
|
|
117
|
-
error: Error;
|
|
118
|
-
result: any;
|
|
119
|
-
}>;
|
|
120
|
-
/**
|
|
121
|
-
* 删除数据
|
|
122
|
-
* @param {string} key 数据键
|
|
123
|
-
* @returns {Promise<{
|
|
124
|
-
* code: number,
|
|
125
|
-
* msg: string,
|
|
126
|
-
* success: true,
|
|
127
|
-
* }|{
|
|
128
|
-
* code: number,
|
|
129
|
-
* msg: string,
|
|
130
|
-
* error: Error,
|
|
131
|
-
* }>}
|
|
132
|
-
*/
|
|
133
|
-
delete: (key: string) => Promise<{
|
|
134
|
-
code: number;
|
|
135
|
-
msg: string;
|
|
136
|
-
success: true;
|
|
137
|
-
} | {
|
|
138
|
-
code: number;
|
|
139
|
-
msg: string;
|
|
140
|
-
error: Error;
|
|
141
|
-
}>;
|
|
142
|
-
/**
|
|
143
|
-
* 删除所有数据
|
|
144
|
-
* @returns {Promise<{
|
|
145
|
-
* code: number,
|
|
146
|
-
* msg: string,
|
|
147
|
-
* error: Error,
|
|
148
|
-
* result: any,
|
|
149
|
-
* }|{
|
|
150
|
-
* code: number,
|
|
151
|
-
* msg: string,
|
|
152
|
-
* success: true,
|
|
153
|
-
* }>}
|
|
154
|
-
*/
|
|
155
|
-
deleteAll: () => Promise<{
|
|
156
|
-
code: number;
|
|
157
|
-
msg: string;
|
|
158
|
-
error: Error;
|
|
159
|
-
result: any;
|
|
160
|
-
} | {
|
|
161
|
-
code: number;
|
|
162
|
-
msg: string;
|
|
163
|
-
success: true;
|
|
164
|
-
}>;
|
|
165
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {...any} args
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
export function TryCatch(...args: any[]): {
|
|
7
|
-
(): void;
|
|
8
|
-
/**
|
|
9
|
-
* 配置
|
|
10
|
-
* @param {{
|
|
11
|
-
* log: boolean
|
|
12
|
-
* }} paramDetails
|
|
13
|
-
*/
|
|
14
|
-
config(paramDetails: {
|
|
15
|
-
log: boolean;
|
|
16
|
-
}): any;
|
|
17
|
-
/**
|
|
18
|
-
* 设置错误处理函数。
|
|
19
|
-
* @param {function|string} handler 错误处理函数,可以是 function 或者 string 类型。如果是 string 类型,则会被当做代码进行执行。
|
|
20
|
-
* @returns 返回 tryCatchObj 函数。
|
|
21
|
-
*/
|
|
22
|
-
error(handler: Function | string): any;
|
|
23
|
-
/**
|
|
24
|
-
* 执行传入的函数并捕获其可能抛出的错误,并通过传入的错误处理函数进行处理。
|
|
25
|
-
* @param {function|string} callback 待执行函数,可以是 function 或者 string 类型。如果是 string 类型,则会被当做代码进行执行。
|
|
26
|
-
* @param {object|null} [__context__] 待执行函数的作用域,用于apply指定
|
|
27
|
-
* @returns 如果函数有返回值,则返回该返回值;否则返回 tryCatchObj 函数以支持链式调用。
|
|
28
|
-
* @throws {Error} 如果传入参数不符合要求,则会抛出相应类型的错误。
|
|
29
|
-
*/
|
|
30
|
-
run(callback: Function | string, __context__?: object | null | undefined): any;
|
|
31
|
-
};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
class UtilsDictionary {
|
|
2
|
-
items = {};
|
|
3
|
-
/**
|
|
4
|
-
* 检查是否有某一个键
|
|
5
|
-
* @param {string} key 键
|
|
6
|
-
* @returns {boolean}
|
|
7
|
-
*/
|
|
8
|
-
has(key) {
|
|
9
|
-
return this.items.hasOwnProperty(key);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 检查已有的键中是否以xx开头
|
|
13
|
-
* @param {string} key 需要匹配的键
|
|
14
|
-
* @returns {boolean}
|
|
15
|
-
*/
|
|
16
|
-
startsWith(key) {
|
|
17
|
-
let allKeys = this.keys();
|
|
18
|
-
for (const keyName of allKeys) {
|
|
19
|
-
if (keyName.startsWith(key)) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 获取以xx开头的键的值
|
|
27
|
-
* @param {string} key 需要匹配的键
|
|
28
|
-
* @returns {any}
|
|
29
|
-
*/
|
|
30
|
-
getStartsWith(key) {
|
|
31
|
-
let allKeys = this.keys();
|
|
32
|
-
for (const keyName of allKeys) {
|
|
33
|
-
if (keyName.startsWith(key)) {
|
|
34
|
-
return this.items[keyName];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* 为字典添加某一个值
|
|
40
|
-
* @param {string} key 键
|
|
41
|
-
* @param {any} val 值,默认为""
|
|
42
|
-
*/
|
|
43
|
-
set(key, val = "") {
|
|
44
|
-
if (key === void 0) {
|
|
45
|
-
throw new Error("Utils.Dictionary().set 参数 key 不能为空");
|
|
46
|
-
}
|
|
47
|
-
this.items[key] = val;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 删除某一个键
|
|
51
|
-
* @param {string} key 键
|
|
52
|
-
* @returns {boolean}
|
|
53
|
-
*/
|
|
54
|
-
delete(key) {
|
|
55
|
-
if (this.has(key)) {
|
|
56
|
-
Reflect.deleteProperty(this.items, key);
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 获取某个键的值
|
|
63
|
-
* @param {string} key 键
|
|
64
|
-
* @returns {any}
|
|
65
|
-
*/
|
|
66
|
-
get(key) {
|
|
67
|
-
return this.has(key) ? this.items[key] : void 0;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* 返回字典中的所有值
|
|
71
|
-
* @returns {any[]}
|
|
72
|
-
*/
|
|
73
|
-
values() {
|
|
74
|
-
let resultList = [];
|
|
75
|
-
for (let prop in this.items) {
|
|
76
|
-
if (this.has(prop)) {
|
|
77
|
-
resultList.push(this.items[prop]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return resultList;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 清空字典
|
|
84
|
-
*/
|
|
85
|
-
clear() {
|
|
86
|
-
this.items = null;
|
|
87
|
-
this.items = {};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 获取字典的长度
|
|
91
|
-
* @returns {number}
|
|
92
|
-
*/
|
|
93
|
-
size() {
|
|
94
|
-
return Object.keys(this.items).length;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* 获取字典所有的键
|
|
98
|
-
*/
|
|
99
|
-
keys() {
|
|
100
|
-
return Object.keys(this.items);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* 返回字典本身
|
|
104
|
-
* @returns {object}
|
|
105
|
-
*/
|
|
106
|
-
getItems() {
|
|
107
|
-
return this.items;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* 合并另一个字典
|
|
111
|
-
* @param {object} data 需要合并的字典
|
|
112
|
-
*/
|
|
113
|
-
concat(data) {
|
|
114
|
-
this.items = Utils.assign(this.items, data.getItems());
|
|
115
|
-
}
|
|
116
|
-
forEach(callbackfn) {
|
|
117
|
-
for (const key in this.items) {
|
|
118
|
-
callbackfn(this.get(key), key, this.items);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* 获取字典的长度,同this.size
|
|
123
|
-
* @returns {number}
|
|
124
|
-
*/
|
|
125
|
-
get length() {
|
|
126
|
-
return this.size();
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* 迭代器
|
|
130
|
-
*/
|
|
131
|
-
get entries() {
|
|
132
|
-
let that = this;
|
|
133
|
-
return function* () {
|
|
134
|
-
let itemKeys = Object.keys(that.getItems());
|
|
135
|
-
for (const keyName of itemKeys) {
|
|
136
|
-
yield [keyName, that.get(keyName)];
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* 是否可遍历
|
|
142
|
-
*/
|
|
143
|
-
get [Symbol.iterator]() {
|
|
144
|
-
let that = this;
|
|
145
|
-
return function () {
|
|
146
|
-
return that.entries();
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* .toString()和.toLocaleString()输出的字符串
|
|
151
|
-
*/
|
|
152
|
-
get [Symbol.toStringTag]() {
|
|
153
|
-
return "UtilsDictionary";
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export { UtilsDictionary };
|