utils-lib-js 1.7.18 → 1.7.19

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.
Files changed (52) hide show
  1. package/README.en.md +337 -319
  2. package/README.md +23 -1
  3. package/dist/bundle/animate.d.ts +25 -0
  4. package/dist/bundle/array.d.ts +1 -1
  5. package/dist/bundle/base.d.ts +2 -1
  6. package/dist/bundle/element.d.ts +1 -1
  7. package/dist/bundle/event.d.ts +1 -1
  8. package/dist/bundle/function.d.ts +1 -1
  9. package/dist/bundle/index.d.ts +7 -0
  10. package/dist/bundle/index.js +1 -1
  11. package/dist/bundle/log.d.ts +1 -1
  12. package/dist/bundle/object.d.ts +1 -1
  13. package/dist/bundle/request.d.ts +1 -1
  14. package/dist/bundle/types.d.ts +9 -0
  15. package/dist/cjs/animate.d.ts +25 -0
  16. package/dist/cjs/array.d.ts +1 -1
  17. package/dist/cjs/base.d.ts +2 -1
  18. package/dist/cjs/element.d.ts +1 -1
  19. package/dist/cjs/event.d.ts +1 -1
  20. package/dist/cjs/function.d.ts +1 -1
  21. package/dist/cjs/index.d.ts +7 -0
  22. package/dist/cjs/index.js +143 -64
  23. package/dist/cjs/log.d.ts +1 -1
  24. package/dist/cjs/object.d.ts +1 -1
  25. package/dist/cjs/request.d.ts +1 -1
  26. package/dist/cjs/types.d.ts +9 -0
  27. package/dist/esm/animate.d.ts +25 -0
  28. package/dist/esm/array.d.ts +1 -1
  29. package/dist/esm/base.d.ts +2 -1
  30. package/dist/esm/element.d.ts +1 -1
  31. package/dist/esm/event.d.ts +1 -1
  32. package/dist/esm/function.d.ts +1 -1
  33. package/dist/esm/index.d.ts +7 -0
  34. package/dist/esm/index.js +138 -65
  35. package/dist/esm/log.d.ts +1 -1
  36. package/dist/esm/object.d.ts +1 -1
  37. package/dist/esm/request.d.ts +1 -1
  38. package/dist/esm/types.d.ts +9 -0
  39. package/dist/umd/animate.d.ts +25 -0
  40. package/dist/umd/array.d.ts +1 -1
  41. package/dist/umd/base.d.ts +2 -1
  42. package/dist/umd/element.d.ts +1 -1
  43. package/dist/umd/event.d.ts +1 -1
  44. package/dist/umd/function.d.ts +1 -1
  45. package/dist/umd/index.d.ts +7 -0
  46. package/dist/umd/index.js +143 -64
  47. package/dist/umd/log.d.ts +1 -1
  48. package/dist/umd/object.d.ts +1 -1
  49. package/dist/umd/request.d.ts +1 -1
  50. package/dist/umd/types.d.ts +9 -0
  51. package/package.json +49 -49
  52. package/pnpm-lock.yaml +0 -423
package/README.en.md CHANGED
@@ -1,516 +1,534 @@
1
1
  # utils-lib-js
2
2
 
3
- #### 介绍
4
- JavaScript工具函数,封装的一些常用的js函数
3
+ #### Introduction
4
+ JavaScript utility functions, packaging some commonly used js functions
5
5
 
6
- #### 软件架构
7
- 软件架构说明
6
+ #### Software Architecture
7
+ Software architecture specification
8
8
 
9
9
 
10
- #### 安装教程
10
+ #### installation tutorial
11
11
 
12
12
  1. pnpm i
13
13
  2. pnpm build
14
14
 
15
- #### 使用说明
15
+ #### Usage instructions
16
16
 
17
- 1. pnpm build(构建)
18
- 2. pnpm debug(调试源码)
17
+ 1. pnpm build
18
+ 2. pnpm debug (debug source)
19
19
 
20
- #### 参与贡献
20
+ #### Contribute
21
21
 
22
- 1. Fork 本仓库
23
- 2. 新建 Feat_xxx 分支
24
- 3. 提交代码
25
- 4. 新建 Pull Request
22
+ 1. Fork the local warehouse
23
+ 2. Create a branch of Feat_xxx
24
+ 3. Submit the code
25
+ 4. Create a Pull Request
26
26
 
27
- #### 功能
28
- 接口:
27
+ #### function
28
+ Interface:
29
29
 
30
30
  export type IKey = string | symbol | number
31
31
 
32
- ##### 对象类型
32
+ ##### Object type
33
33
 
34
34
  export interface IObject<T> {
35
- [key: IKey]: T | IObject<any>
35
+ [key: IKey]: T | IObject<any>
36
36
  }
37
37
 
38
38
  export interface IPromise extends IObject<any> {
39
- promise: Promise<void>
40
- resolve: (res: any) => unknown
41
- reject: (err: any) => unknown
39
+ promise: Promise<void>
40
+ resolve: (res: any) => unknown
41
+ reject: (err: any) => unknown
42
42
  }
43
43
 
44
44
  export type IInstance<T> = {
45
- _instance: Function
45
+ _instance: Function
46
46
  } & T
47
47
 
48
48
  export type IDemoteArray<T> = Array<IDemoteArray<T> | T>
49
49
 
50
50
  ##### base
51
51
 
52
- /**产生区间随机数
53
- * @param {number} min 最小区间
54
- * @param {number} max 最大区间
55
- * @param {boolean} bool 包含最大值
56
- * @return {number} 随机数
57
- **/
52
+ /** Generates interval random numbers
53
+ * @param {number} min Minimum interval
54
+ * @param {number} max Maximum range
55
+ * @param {boolean} bool Contains the maximum value
56
+ * @return {number} A random number
57
+ * * /
58
58
 
59
- export type IRandomNum = (min: number, max: number, bool?: boolean) => number
59
+ export type IRandomNum = (min: number, max: number, bool? : boolean) => number
60
60
 
61
- /**获取url的参数
62
- * @param {string} url 待截取的地址
63
- * @return {object} 参数对象
64
- **/
61
+ /** Gets the parameters of the url
62
+ * @param {string} url Indicates the address to be intercepted
63
+ * @return {object} Parameter object
64
+ * * /
65
65
 
66
66
  export type IUrlSplit = (url: string) => IObject<any>
67
67
 
68
- /**添加url的参数
69
- * @param {string} url 待添加参数的地址
70
- * @param {object} query 待添加的参数
71
- * @return {string} 添加参数后的url
72
- **/
68
+ /** Adds parameters for the url
69
+ * @param {string} url Address to which the parameter is to be added
70
+ * @param {object} query Specifies the parameter to be added
71
+ * @return {string} The url after the parameter is added
72
+ * * /
73
73
 
74
74
  export type IUrlJoin = (url: string, query: object) => string
75
75
 
76
- /**获取数据类型
77
- * @param {any} data 待检测数据
78
- * @return {string} 数据类型
79
- **/
76
+ /** Gets the data type
77
+ * @param {any} data Indicates the data to be detected
78
+ * @return {string} Data type
79
+ * * /
80
80
 
81
81
  export type IGetType<T> = (data: any) => typeof data | T[keyof T] | "null";
82
82
 
83
- /**批量判断数据类型
84
- * @param {any} data 待检测数据
85
- * @param {any} whiteList 数据类型名单
86
- * @return {boolean} 是否在白名单中
87
- **/
83
+ /** Determine the data type in batches
84
+ * @param {any} data Indicates the data to be detected
85
+ * @param {any} whiteList Indicates a list of data types
86
+ * @return {boolean} Whether it is in the whitelist
87
+ * * /
88
88
 
89
89
  export type IGetTypeByList = (data: any, whiteList: string[]) => boolean;
90
90
 
91
91
 
92
92
  ##### object
93
93
 
94
- /**lodash中的 _.get(),获取对象某级属性
95
- * @param {IObject} object 目标对象
96
- * @param {string} key 对象层级
97
- * @param {any} defaultValue 未取得时默认值
98
- * @return {IObject[IKey]} 对象某个属性
99
- **/
94
+ /**lodash _.get() to get a certain level attribute of the object
95
+ * @param {IObject} object Indicates the target object
96
+ * @param {string} key object hierarchy
97
+ * @param {any} defaultValue Default value if not obtained
98
+ * @return {IObject[IKey]} A property of an object
99
+ * * /
100
100
 
101
- export type IGetValue = <T, U = IObject<T> | IObject<T>[IKey]>(object: U, key: string, defaultValue?: any) => U
101
+ export type IGetValue = <T, U = IObject<T> | IObject<T>[IKey]>(object: U, key: string, defaultValue? : any) => U
102
102
 
103
- /**lodash中的 _.set(),赋值对象某级属性
104
- * @param {IObject} object 目标对象
105
- * @param {string} key 对象层级
106
- * @param {any} value 需要赋的值
107
- * @return {IObject} 目标对象
108
- **/
103
+ /**lodash _.set(), which assigns a level attribute to the object
104
+ * @param {IObject} object Indicates the target object
105
+ * @param {string} key object hierarchy
106
+ * @param {any} value Specifies the value to be assigned
107
+ * @return {IObject} Target object
108
+ * * /
109
109
 
110
- export type ISetValue = <T>(object: IObject<T>, key: string, value?: any) => IObject<T>
110
+ export type ISetValue = <T>(object: IObject<T>, key: string, value? : any) => IObject<T>
111
111
 
112
- /**对象混入
113
- * @param {IObject} target 目标对象
114
- * @param {string} source 需要混入的对象集合
115
- * @param {boolean} overwrite 是否重写覆盖原有属性
116
- * @return {IObject} 目标对象
117
- **/
112
+ /** Object mixed in
113
+ * @param {IObject} target Indicates the target object
114
+ * @param {string} source Set of objects to be mixed in
115
+ * @param {boolean} overwrite Whether to overwrite the original attribute
116
+ * @return {IObject} Target object
117
+ * * /
118
118
 
119
- export type IMixIn = <U extends IObject<any>>(target?: U, source?: IObject<any>, overwrite?: boolean) => U
119
+ export type IMixIn = <U extends IObject<any>>(target? : U, source? : IObject<any>, overwrite? : boolean) => U
120
120
 
121
- /**枚举值反向映射
122
- * @param {IObject<string>} target 目标对象
123
- * @return {IObject<string>} 目标对象
124
- **/
121
+ /** Enumeration value reverse mapping
122
+ * @param {IObject<string>} target Indicates the target object
123
+ * @return {IObject<string>} Target object
124
+ * * /
125
125
 
126
126
  export type IEnumInversion = (target: IObject<string>) => IObject<string>
127
127
 
128
- /**对象复制
129
- * @param {IObject<any>} target 目标对象
130
- * @return {IObject} 目标对象
131
- **/
128
+ /** Object replication
129
+ * @param {IObject<any>} target Indicates the target object
130
+ * @return {IObject} Target object
131
+ * * /
132
132
 
133
- export type ICloneDeep = (target?: any) => any
133
+ export type ICloneDeep = (target? : any) => any
134
134
 
135
- /**生成 对象 类型的初始值
136
- * @param {string} type 数据类型
137
- * @param {any} __init 初始值
138
- * @return {any} 目标对象
139
- **/
135
+ /** Generates the initial value of the object type
136
+ * @param {string} type Indicates the data type
137
+ * @param {any} __init Initial value
138
+ * @return {any} Target object
139
+ * * /
140
140
 
141
- export type ICreateObjectVariable = (type: string, source?: any) => any
141
+ export type ICreateObjectVariable = (type: string, source? : any) => any
142
142
 
143
- /**Object.create 根据源对象产出新对象
144
- * @param {Function|Object} source 源对象
145
- * @return {Function|Object} 对象产物
146
- **/
143
+ /** object. create generates a new Object based on the source object
144
+ * @param {Function|Object} source Source object
145
+ * @return {Function|Object} Object product
146
+ * * /
147
147
 
148
148
  export type ICreateObject = <T, U extends T>(source: T) => U
149
149
 
150
- /**类的继承
151
- * @param {Function} source 源对象
152
- * @return {Function} 继承产物
153
- **/
150
+ Inheritance of the /** class
151
+ * @param {Function} source Source object
152
+ * @return {Function} inheritance product
153
+ * * /
154
154
 
155
- export type IInherit = <T extends Function>(source: T, target?: Function) => Function
155
+ export type IInherit = <T extends Function>(source: T, target? : Function) => Function
156
156
 
157
- /**生成类的实例单例
158
- * @param {Function} classProto
159
- * @param {Boolean} overwrite 是否覆盖已有单例
160
- * @param {any[]} params 构造函数的参数
161
- * @return {IObject} 实例化的单例
162
- **/
157
+ /** Generates an instance singleton of the class
158
+ * @param {Function} classProto class
159
+ * @param {Boolean} overwrite Whether to overwrite an existing singleton
160
+ * @param {any[]} Parameter of the params constructor
161
+ * @return {IObject} instantiated singleton
162
+ * * /
163
163
 
164
- export type IGetInstance = (classProto: IInstance<FunctionConstructor>, overwrite?: boolean, ...params: any[]) => Function
164
+ export type IGetInstance = (classProto: IInstance<FunctionConstructor>, overwrite? : boolean, ... params: any[]) => Function
165
165
 
166
- /**通过装饰器将属性混入类中
167
- * @param {IObject<any>} params 混入的属性
168
- * @return {ClassDecorator} 装饰器钩子函数
169
- **/
166
+ /** Mixes attributes into classes via decorators
167
+ * @param {IObject<any>} params mixed property
168
+ * @return {ClassDecorator} Decorator hook function
169
+ * * /
170
170
 
171
171
  export type IClassDecorator = (params: IObject<any>) => <TFunction extends Function>(target: TFunction) => void
172
172
 
173
- /**JSON.parse封装
174
- * @param {string} target 字符串
175
- * @return {IObject<any>} 对象
176
- **/
173
+ /**JSON.parse package
174
+ * @param {string} target string
175
+ * @return {IObject<any>} object
176
+ * * /
177
177
 
178
178
  export type IStringToJson = (target: string) => IObject<any>
179
179
 
180
- /**JSON.stringify封装
181
- * @param {IObject<any>} target 对象
182
- * @return {string} 字符串
183
- **/
180
+ /**JSON.stringify encapsulation
181
+ * @param {IObject<any>} target object
182
+ * @return {string} A string
183
+ * * /
184
184
 
185
185
  export type IJsonToString = (target: IObject<any>) => string
186
186
 
187
187
  ##### function
188
188
 
189
- /**节流(throttle):高频事件触发,但在 n 秒内只会执行一次
190
- * @param {Function} fn 节流处理的函数
191
- * @param {number} time 执行间隔/毫秒
192
- * @return {Function} 处理后的函数
193
- **/
189
+ /** throttle: A high-frequency event is triggered, but only once in n seconds
190
+ * @param {Function} fn Function for throttling
191
+ * @param {number} time Execution interval/ms
192
+ * @return {Function} Function after processing
193
+ * * /
194
194
 
195
- export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void
195
+ export type IThrottle = (fn: Function, time: number) => (... args: any[]) => void
196
196
 
197
- /**防抖(debounce):触发高频事件后 n 秒内函数只会执行一次
198
- * @param {Function} fn 防抖处理的函数
199
- * @param {number} time 允许运行函数间隔/毫秒
200
- * @return {Function} 处理后的函数
201
- **/
197
+ /** debounce: The function executes only once within n seconds after a high-frequency event is triggered
198
+ * @param {Function} fn Function for anti-shake processing
199
+ * @param {number} time Allows running function intervals/milliseconds
200
+ * @return {Function} Function after processing
201
+ * * /
202
202
 
203
- export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void
203
+ export type IDebounce = (fn: Function, time: number) => (... args: any[]) => void
204
204
 
205
- /**
206
- * Promise扁平化,避免Promise嵌套
207
- * @param {number} timer 超时
208
- * @returns {Promise,resolve,reject}
209
- */
205
+ / * *
206
+ * Promise flattening to avoid Promise nesting
207
+ * @param {number} timer times out
208
+ * @returns {Promise,resolve,reject}
209
+ * /
210
210
  export type IDefer = (timer: number) => IPromise
211
211
 
212
- /**awaittry catch 捕获异常处理方法
213
- * @param {Promise<any>} defer 延迟函数
214
- * @returns {Promise<any>} [error, result]
215
- */
216
-
212
+ /**await and try catch catch exception handling methods
213
+ * @param {Promise<any>} defer the delay function
214
+ * @returns {Promise<any>} [error, result]
215
+ * /
217
216
  export type ICatchAwait<T extends Promise<any>> = (defer: T) => T
218
-
219
217
  ##### array
220
218
 
221
- /**数组乱序
222
- * @param {Array<any>} arr 目标数组
223
- * @returns {Array<any>} 乱序后的数组
224
- */
225
-
219
+ /** The array is out of order
220
+ * @param {Array<any>} arr target array
221
+ * @returns {Array<any>} The array is out of order
222
+ * /
223
+
226
224
  export type IArrayRandom<T extends any[]> = (arr: T) => T
227
225
 
228
- /**数组数组去重
229
- * @param {Array<any>} arr 目标数组
230
- * @returns {Array<any>} 去重后的数组
231
- */
226
+ /** array array weight removal
227
+ * @param {Array<any>} arr target array
228
+ * @returns {Array<any>} Specifies the array after deduplication
229
+ * /
232
230
 
233
231
  export type IArrayUniq<T extends any[]> = (arr: T) => T
234
232
 
235
- /**数组扁平化
236
- * @param {Array<any>} arr 目标数组
237
- * @returns {Array<any>} 扁平化的数组
238
- */
233
+ /** Array flattens
234
+ * @param {Array<any>} arr target array
235
+ * @returns {Array<any>} A flat array
236
+ * /
239
237
 
240
- export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T
238
+ export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result? : T) => T
241
239
 
242
240
  ##### element
243
241
 
244
242
  /**IElementParams
245
- * @param {string} ele 标签类型
246
- * @param {CSSStyleDeclaration} style 样式
247
- * @param {Attr} attr 属性
248
- * @param {object} parent 父元素
249
- */
243
+ * @param {string} ele Label type
244
+ * @param {CSSStyleDeclaration} style
245
+ * @param {Attr} attr attribute
246
+ * @param {object} parent Parent element
247
+ * /
250
248
 
251
249
  interface IElementParams<T> {
252
- ele: T | string
253
- style: CSSStyleDeclaration
254
- attr: Attr
255
- parent: T
250
+ ele: T | string
251
+ style: CSSStyleDeclaration
252
+ attr: Attr
253
+ parent: T
256
254
  }
257
255
 
258
- /**新增标签,设置属性及样式
259
- * @param {IElementParams} params 配置
260
- * @return {ElementObject} 生成的标签
261
- */
256
+ /** Add labels, set properties and styles
257
+ * @param {IElementParams} params configuration
258
+ * @return {ElementObject} Generated label
259
+ * /
262
260
 
263
261
  export type ICreateElement<T = HTMLElement> = (params: IElementParams<T>) => T
264
262
 
265
263
  ##### event
266
264
 
267
- /**浏览器事件
268
- * @param {Document} ele 标签
269
- * @param {string} type 事件类型
270
- * @param {(e: Event) => void} handler 事件回调
271
- * @return {void}
272
- */
265
+ /** Browser events
266
+ * @param {Document} ele tag
267
+ * @param {string} type Event type
268
+ * @param {(e: Event) => void} handler Event callback
269
+ * @return {void}
270
+ * /
273
271
 
274
272
  export type IAddHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void
275
273
 
276
- /**取消事件冒泡
277
- * @param {Event} e 浏览器事件对象
278
- * @return {void}
279
- */
274
+ /** Cancel event bubbling
275
+ * @param {Event} e Browser event object
276
+ * @return {void}
277
+ * /
280
278
 
281
279
  export type IStopBubble = (e: Event) => void
282
280
 
283
- /**取消默认事件
284
- * @param {Event} e 浏览器事件对象
285
- * @return {void}
286
- */
281
+ /** Cancels the default event
282
+ * @param {Event} e Browser event object
283
+ * @return {void}
284
+ * /
287
285
 
288
286
  export type IStopDefault = (e: Event) => void
289
287
 
290
- /**取消浏览器事件
291
- * @param {Document} ele 标签
292
- * @param {string} type 事件类型
293
- * @param {(e: Event) => void} handler 事件回调
294
- * @return {void}
295
- */
288
+ /** Cancels browser events
289
+ * @param {Document} ele tag
290
+ * @param {string} type Event type
291
+ * @param {(e: Event) => void} handler Event callback
292
+ * @return {void}
293
+ * /
296
294
 
297
295
  export type IRemoveHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void
298
296
 
299
- /**取消默认事件
300
- * @param {Event} e 浏览器事件对象
301
- * @return {void}
302
- */
297
+ /** Cancels the default event
298
+ * @param {Event} e Browser event object
299
+ * @return {void}
300
+ * /
303
301
 
304
302
  export type IDispatchEvent = <T extends Document>(ele: T, data: any) => void
305
303
 
306
304
 
307
305
  ##### log
308
306
 
309
- /** 单行输出
310
- * @param {string} str 输出字符
311
- * @param {boolean} overwrite 覆盖前面的输出
312
- * @param {boolean} warp 最后一行换行
313
- * @return {void}
314
- */
315
- export type ILogOneLine = (str: string, overwrite?: boolean, warp?: boolean) => void
316
-
317
- /** 循环输出某个队列
318
- * @param {string[]} loopList 输出的字符队列
319
- * @param {number} index 第几个字符
320
- * @param {boolean} isStop 控制暂停循环
321
- * @param {number} timer 两个相隔时间间隔
322
- */
307
+ /** Single line output
308
+ * @param {string} str Output character
309
+ * @param {boolean} overwrite overwrites the previous output
310
+ * @param {boolean} warp Wrap the last line
311
+ * @return {void}
312
+ * /
313
+ export type ILogOneLine = (str: string, overwrite? : boolean, warp? : boolean) => void
314
+
315
+ /** Loops out a queue
316
+ * @param {string[]} loopList Indicates the output character queue
317
+ * @param {number} index The number of characters
318
+ * @param {boolean} isStop Control pause loop
319
+ * @param {number} timer Indicates two interval times
320
+ * /
323
321
  export type ILogLoopParams = {
324
- loopList?: string[]
325
- index?: number
326
- isStop?: boolean
327
- timer?: number
322
+ loopList? : string[]
323
+ index? : number
324
+ isStop? : boolean
325
+ timer? : number
328
326
  }
329
- export type ILogLoop = (opts?: ILogLoopParams) => ILogLoopParams | void
327
+ export type ILogLoop = (opts? : ILogLoopParams) => ILogLoopParams | void
330
328
 
331
329
  ##### request
332
330
 
333
331
  export type IRequestParams<T> = T | IObject<any> | null
334
332
 
335
- // 请求路径
333
+ // Request path
336
334
 
337
335
  export type IUrl = string
338
336
 
339
- // 环境判断
337
+ // Environmental judgment
340
338
 
341
339
  export type IEnv = 'Window' | 'Node'
342
340
 
343
- // fetch返回取值方式
341
+ // fetch Returns the value
344
342
 
345
343
  export type IDataType = "text" | "json" | "blob" | "formData" | "arrayBuffer"
346
344
 
347
- // 请求方式
345
+ // Request mode
348
346
 
349
347
  export type IRequestMethods = "GET" | "POST" | "DELETE" | "PUT" | "OPTION"
350
348
 
351
- // body结构
349
+ // body structure
352
350
 
353
351
  export type IRequestBody = IRequestParams<BodyInit>
354
352
 
355
- // heads结构
353
+ // heads structure
356
354
 
357
355
  export type IRequestHeaders = IRequestParams<HeadersInit>
358
356
 
359
- // 请求基础函数
357
+ // Request the base function
360
358
 
361
359
  export type IRequestBaseFn = (url: IUrl, opts: IRequestOptions) => Promise<any>
362
360
 
363
- // 请求函数体
361
+ // Request function body
364
362
 
365
- export type IRequestFn = (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => Promise<any>
363
+ export type IRequestFn = (url? : IUrl, query? : IObject<any>, body? : IRequestBody, opts? : IRequestOptions) => Promise<any>
366
364
 
367
- // 请求参数
365
+ // Request parameters
368
366
 
369
367
  export type IRequestOptions = {
370
- method?: IRequestMethods
371
- query?: IRequestParams<IObject<any>>
372
- body?: IRequestBody
373
- headers?: IRequestHeaders
374
- controller?: AbortController
375
- timeout?: number
376
- timer?: number | unknown | null
377
- [key: string]: any
368
+ method? : IRequestMethods
369
+ query? : IRequestParams<IObject<any>>
370
+ body? : IRequestBody
371
+ headers? : IRequestHeaders
372
+ controller? : AbortController
373
+ timeout? : number
374
+ timer? : number | unknown | null
375
+ [key: string]: any
378
376
  }
379
377
 
380
- // 拦截器
378
+ // Interceptor
381
379
 
382
380
  export type IInterceptors = {
383
- use(type: "request" | "response" | "error", fn: Function): void
384
- get reqFn(): Function
385
- get resFn(): Function
386
- get errFn(): Function
381
+ use(type: "request" | "response" | "error", fn: Function): void
382
+ get reqFn(): Function
383
+ get resFn(): Function
384
+ get errFn(): Function
387
385
  }
388
386
 
389
- // 公共函数
387
+ // Public function
390
388
 
391
389
  export type IRequestBase = {
392
- readonly origin: string
393
- chackUrl: (url: IUrl) => boolean
394
- envDesc: () => IEnv
395
- errorFn: <Err = any, R = Function>(reject: R) => (err: Err) => R
396
- clearTimer: (opts: IRequestOptions) => void
397
- initAbort: <T = IRequestOptions>(opts: T) => T
398
- requestType: () => IRequestBaseFn
399
- fixOrigin: (fixStr: string) => string
400
- fetch: IRequestBaseFn
401
- http: IRequestBaseFn
402
- getDataByType: (type: IDataType, response: Response) => Promise<any>
390
+ readonly origin: string
391
+ chackUrl: (url: IUrl) => boolean
392
+ envDesc: () => IEnv
393
+ errorFn: <Err = any, R = Function>(reject: R) => (err: Err) => R
394
+ clearTimer: (opts: IRequestOptions) => void
395
+ initAbort: <T = IRequestOptions>(opts: T) => T
396
+ requestType: () => IRequestBaseFn
397
+ fixOrigin: (fixStr: string) => string
398
+ fetch: IRequestBaseFn
399
+ http: IRequestBaseFn
400
+ getDataByType: (type: IDataType, response: Response) => Promise<any>
403
401
  }
404
402
 
405
- // 初始化参数
403
+ // Initialize parameters
406
404
 
407
405
  export type IRequestInit = {
408
- initDefaultParams: (url: IUrl, opts: IRequestOptions) => any
409
- initFetchParams: (url: IUrl, opts: IRequestOptions) => any
410
- initHttpParams: (url: IUrl, opts: IRequestOptions) => any
406
+ initDefaultParams: (url: IUrl, opts: IRequestOptions) => any
407
+ initFetchParams: (url: IUrl, opts: IRequestOptions) => any
408
+ initHttpParams: (url: IUrl, opts: IRequestOptions) => any
411
409
  }
412
410
 
413
- // 请求主体类
411
+ // Request principal class
414
412
 
415
413
  export type IRequest = {
416
- GET: IRequestFn
417
- POST: IRequestFn
418
- DELETE: IRequestFn
419
- PUT: IRequestFn
420
- OPTIONS: IRequestFn
421
- HEAD: IRequestFn
422
- PATCH: IRequestFn
414
+ GET: IRequestFn
415
+ POST: IRequestFn
416
+ DELETE: IRequestFn
417
+ PUT: IRequestFn
418
+ OPTIONS: IRequestFn
419
+ HEAD: IRequestFn
420
+ PATCH: IRequestFn
423
421
  } & IRequestBase
424
-
425
-
426
- <!-- 消息中心 -->
427
- // 消息中心
422
+ <! -- News Center -->
423
+ // Message Center
428
424
  export declare interface Handlers {
429
- [key: string]: Array<Function>
425
+ [key: string]: Array<Function>
430
426
  }
431
427
  export declare interface IMessageCenter {
432
- events: Handlers
433
- _instance?: IMessageCenter
434
- on: (type: string, handler: Function) => this
435
- emit: (type: string, data?: any) => this
436
- un: (type: string, handler?: Function) => this
437
- once: (type: string, handler: Function) => this
438
- clear: () => this
439
- has: (type: string) => boolean
440
- handlerLength: (type: string) => number
441
- watch: (type: string, handler: Function) => this
442
- invoke: (type: string, data?: any) => Promise<void>
428
+ events: Handlers
429
+ _instance? : IMessageCenter
430
+ on: (type: string, handler: Function) => this
431
+ emit: (type: string, data? : any) => this
432
+ un: (type: string, handler? : Function) => this
433
+ once: (type: string, handler: Function) => this
434
+ clear: () => this
435
+ has: (type: string) => boolean
436
+ handlerLength: (type: string) => number
437
+ watch: (type: string, handler: Function) => this
438
+ invoke: (type: string, data? : any) => Promise<void>
443
439
  }
444
440
 
445
441
  https://gitee.com/DieHunter/message-center
446
442
 
447
- <!-- 任务队列 -->
443
+ <! -- Task Queue -->
448
444
 
449
- /**
450
- * 单条队列
451
- * defer: 待运行的异步函数
452
- * params?: defer的参数,也可以用bind直接传递
453
- *
454
- */
445
+ / * *
446
+ * Single queue
447
+ * defer: asynchronous function to be run
448
+ * params? The: defer parameter can also be passed directly using bind
449
+ *
450
+ * /
455
451
  export interface IQueue {
456
- defer: Function
457
- name?: string
452
+ defer: Function
453
+ name? : string
458
454
  }
459
- /**
460
- * 队列参数
461
- * children: 队列列表
462
- * name: 队列唯一标识
463
- * result: 运行完成后的结果
464
- *
465
- */
455
+ / * *
456
+ * Queue parameter
457
+ * children: Queue list
458
+ * name: indicates the unique identifier of the queue
459
+ * result: indicates the result after the run is complete
460
+ *
461
+ * /
466
462
  export interface IQueues {
467
- children: Array<Function>
468
- name: string
469
- result?: any[]
463
+ children: Array<Function>
464
+ name: string
465
+ result? : any[]
470
466
  }
471
- /**
472
- * 队列缓存
473
- */
467
+ / * *
468
+ * queue cache
469
+ * /
474
470
  export type IQueueTemp = {
475
- [key: string]: IQueues
471
+ [key: string]: IQueues
476
472
  }
477
- /**
478
- * 系统队列
479
- */
473
+ / * *
474
+ * System queue
475
+ * /
480
476
  export type IQueueList = Array<IQueue>
481
- /**
482
- * 队列状态 idle:空闲 pending:等待 fulfilled:完成 rejected:失败
483
- */
477
+ / * *
478
+ * The queue status idle: idle pending: waiting fulfilled: completed rejected: failed
479
+ * /
484
480
  export type IState = "idle" | "pending" | "fulfilled" | "rejected"
485
- /**
486
- * 任务队列参数
487
- */
481
+ / * *
482
+ * Task queue parameters
483
+ * /
488
484
  export type ITaskQueueProps = {
489
- maxLen: number
485
+ maxLen: number
490
486
  }
491
- /**
492
- * 任务队列
493
- */
487
+ / * *
488
+ * Task queue
489
+ * /
494
490
  export type ITaskQueue = {
495
- readonly fix: string
496
- props: ITaskQueueProps
497
- queueTemp: IQueueTemp
498
- queues: IQueueList
499
- state: IState
500
- push: (queue: IQueues) => Promise<void>
501
- unshift: (length: number) => IQueueList
502
- run: (reject: any) => unknown
503
- clear: () => void
491
+ readonly fix: string
492
+ props: ITaskQueueProps
493
+ queueTemp: IQueueTemp
494
+ queues: IQueueList
495
+ state: IState
496
+ push: (queue: IQueues) => Promise<void>
497
+ unshift: (length: number) => IQueueList
498
+ run: (reject: any) => unknown
499
+ clear: () => void
504
500
  }
505
501
 
506
502
  https://gitee.com/DieHunter/task-queue
507
503
 
508
- /** 单行输出
509
- * @param {string} str 输出字符
510
- * @param {boolean} overwrite 覆盖前面的输出
511
- * @param {boolean} warp 最后一行换行
512
- * @return {void}
513
- */
504
+ /** Single line output
505
+ * @param {string} str Output character
506
+ * @param {boolean} overwrite overwrites the previous output
507
+ * @param {boolean} warp Wrap the last line
508
+ * @return {void}
509
+ * /
514
510
  export function logOneLine(str: string): void
515
- export function logOneLine(str: string, overwrite?: boolean): void
516
- export function logOneLine(str: string, overwrite?: boolean, warp?: boolean): void
511
+ export function logOneLine(str: string, overwrite? : boolean): void
512
+ export function logOneLine(str: string, overwrite? : boolean, warp? : boolean): void
513
+
514
+
515
+ // animate
516
+
517
+ / * *
518
+ * Animation
519
+ * reference: https://gitee.com/DieHunter/myCode/tree/master/%E5%89%8D%E7%AB%AF%E5%8A%A8%E7%94%BB/js
520
+ *
521
+ * /
522
+ export type IAnimateFrame = {
523
+ id: number | null // Animation index
524
+ duration: number // Frame number control
525
+ isActive: boolean// Activate control
526
+ fn(timer: number): void
527
+ start(duration: number): void
528
+ stop(): void
529
+ animate(timer: number): void
530
+ }
531
+ declare var IAnimateFrame: {
532
+ new(fn: (timer: number) => void): IAnimateFrame
533
+ prototype: IAnimateFrame
534
+ }