mazey 3.1.0 → 3.3.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 +48 -12
- package/{src/example.html → examples/index.html} +0 -0
- package/examples/index.ts +32 -0
- package/index.js +44 -0
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +229 -116
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/mazey.min.js +1 -1
- package/package.json +5 -4
- package/src/index.ts +344 -133
- package/webpack.config.dev.js +39 -0
- package/src/example.ts +0 -49
package/lib/index.d.ts
CHANGED
|
@@ -3,232 +3,238 @@
|
|
|
3
3
|
* @description Computes the longest common substring of two strings.
|
|
4
4
|
* @param {string} aStr String
|
|
5
5
|
* @param {string} bStr String
|
|
6
|
-
* @
|
|
6
|
+
* @returns {number} Length
|
|
7
7
|
*/
|
|
8
|
-
export declare function calLongestCommonSubstring(aStr
|
|
8
|
+
export declare function calLongestCommonSubstring(aStr: string, bStr: string): number;
|
|
9
9
|
/**
|
|
10
10
|
* @method calLongestCommonSubsequence
|
|
11
11
|
* @description 计算两个字符串的最长公共子序列
|
|
12
12
|
* @param {string} aStr 字符串
|
|
13
13
|
* @param {string} bStr 字符串
|
|
14
|
-
* @
|
|
14
|
+
* @returns {number} 长度
|
|
15
15
|
*/
|
|
16
|
-
export declare function calLongestCommonSubsequence(aStr
|
|
16
|
+
export declare function calLongestCommonSubsequence(aStr: string, bStr: string): number;
|
|
17
17
|
/**
|
|
18
18
|
* @method getQueryParam
|
|
19
19
|
* @description Get the query param's value of the current Web URL(`location.search`).
|
|
20
20
|
* @param {string} param Query param.
|
|
21
|
-
* @
|
|
22
|
-
|
|
23
|
-
export declare function getQueryParam(param
|
|
21
|
+
* @returns {string} value
|
|
22
|
+
*/
|
|
23
|
+
export declare function getQueryParam(param: string): string;
|
|
24
24
|
/**
|
|
25
25
|
* @method getUrlParam
|
|
26
26
|
* @description Get the query param's value of the input URL.
|
|
27
27
|
* @param {string} url URL string.
|
|
28
28
|
* @param {string} param Query param.
|
|
29
|
-
* @
|
|
30
|
-
|
|
31
|
-
export declare function getUrlParam(url
|
|
29
|
+
* @returns {string} value
|
|
30
|
+
*/
|
|
31
|
+
export declare function getUrlParam(url: string, param: string): string | string[];
|
|
32
32
|
/**
|
|
33
33
|
* @method updateQueryParam
|
|
34
34
|
* @description Update the query param's value of the input URL.
|
|
35
35
|
* @param {string} url URL string.
|
|
36
36
|
* @param {string} param Query param.
|
|
37
37
|
* @param {string} value Param's value.
|
|
38
|
-
* @
|
|
39
|
-
|
|
40
|
-
export declare function updateQueryParam(url
|
|
38
|
+
* @returns {string} URL.
|
|
39
|
+
*/
|
|
40
|
+
export declare function updateQueryParam(url: string, param: string, value: string): string;
|
|
41
41
|
/**
|
|
42
42
|
* @method getHashQueryParam
|
|
43
43
|
* @description Get the hash query param's value of the current Web URL(`location.hash`).
|
|
44
44
|
* @param {string} param Query param.
|
|
45
|
-
* @
|
|
45
|
+
* @returns {string} value
|
|
46
46
|
*/
|
|
47
|
-
export declare function getHashQueryParam(param
|
|
47
|
+
export declare function getHashQueryParam(param: string): string;
|
|
48
48
|
/**
|
|
49
49
|
* @method getDomain
|
|
50
50
|
* @description Get the domain of URL, and other params.
|
|
51
51
|
* @param {string} url
|
|
52
52
|
* @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
53
|
-
|
|
54
|
-
export declare function getDomain(url
|
|
53
|
+
*/
|
|
54
|
+
export declare function getDomain(url: string, rules?: string[]): string;
|
|
55
55
|
/**
|
|
56
56
|
* @method camelCaseToKebabCase
|
|
57
57
|
* @description Transfer CamelCase to KebabCase.
|
|
58
58
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
59
|
-
* @
|
|
60
|
-
|
|
61
|
-
export declare function camelCaseToKebabCase(camelCase
|
|
59
|
+
* @returns {string} 'a-b-c'
|
|
60
|
+
*/
|
|
61
|
+
export declare function camelCaseToKebabCase(camelCase: string): string;
|
|
62
62
|
/**
|
|
63
63
|
* @method camelCase2Underscore
|
|
64
64
|
* @description Transfer CamelCase to Underscore.
|
|
65
65
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
66
|
-
* @
|
|
67
|
-
|
|
68
|
-
export declare function camelCase2Underscore(camelCase
|
|
66
|
+
* @returns {string} 'a_b_c'
|
|
67
|
+
*/
|
|
68
|
+
export declare function camelCase2Underscore(camelCase: string): string;
|
|
69
69
|
/**
|
|
70
70
|
* @method mTrim
|
|
71
71
|
* @description Remove leading and trailing whitespace or specified characters from string.
|
|
72
72
|
* @param {string} str The string to trim.
|
|
73
|
-
* @
|
|
74
|
-
|
|
75
|
-
export declare function mTrim(str
|
|
73
|
+
* @returns {string} Trimmed string.
|
|
74
|
+
*/
|
|
75
|
+
export declare function mTrim(str: string): string;
|
|
76
76
|
/**
|
|
77
77
|
* @method newLine
|
|
78
78
|
* @description Make a newline of HTML.
|
|
79
79
|
* @param {string} str The string to make a newline.
|
|
80
|
-
* @
|
|
81
|
-
|
|
82
|
-
export declare function newLine(str
|
|
80
|
+
* @returns {string} A newline with `br`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function newLine(str: string): string;
|
|
83
83
|
/**
|
|
84
84
|
* @method deepCopyObject
|
|
85
85
|
* @description Clone Object deeply.
|
|
86
86
|
* @param {object} obj The value to clone.
|
|
87
|
-
* @
|
|
88
|
-
|
|
87
|
+
* @returns {object} Returns the deep cloned value.
|
|
88
|
+
*/
|
|
89
89
|
export declare function deepCopyObject(obj: any): any;
|
|
90
90
|
/**
|
|
91
91
|
* @method isJsonString
|
|
92
92
|
* @description Check whether it is a valid JSON string.
|
|
93
93
|
* @param {string} str The string to check.
|
|
94
|
-
* @
|
|
95
|
-
|
|
96
|
-
export declare function isJsonString(str
|
|
94
|
+
* @returns {boolean} Return the result of checking.
|
|
95
|
+
*/
|
|
96
|
+
export declare function isJsonString(str: string): boolean;
|
|
97
97
|
/**
|
|
98
98
|
* @method generateRndNum
|
|
99
99
|
* @description Produce a random string of number, `generateRndNum(7)` => '7658495'.
|
|
100
100
|
* @param {number} n Length
|
|
101
|
-
* @
|
|
102
|
-
|
|
101
|
+
* @returns {string} Return the random string.
|
|
102
|
+
*/
|
|
103
103
|
export declare function generateRndNum(n?: number): string;
|
|
104
104
|
/**
|
|
105
105
|
* @method generateUniqueNum
|
|
106
106
|
* @description 根据时间生成唯一标志的数字 mGenerateUniqueNum() => 1538324722364123。
|
|
107
107
|
* @param {number} n 随机数的长度
|
|
108
|
-
|
|
108
|
+
*/
|
|
109
109
|
export declare function generateUniqueNum(n?: number): string;
|
|
110
110
|
/**
|
|
111
111
|
* @method floatToPercent
|
|
112
112
|
* @description 浮点数转为百分比 0.2 => 20%。
|
|
113
113
|
* @param {number} num 浮点数
|
|
114
114
|
* @param {number} fixSize 保留几位浮点数
|
|
115
|
-
|
|
116
|
-
export declare function floatToPercent(num
|
|
115
|
+
*/
|
|
116
|
+
export declare function floatToPercent(num: number, fixSize?: number): string;
|
|
117
117
|
/**
|
|
118
118
|
* @method floatFixed
|
|
119
119
|
* @description 浮点数保留指定位。
|
|
120
|
-
|
|
120
|
+
*/
|
|
121
121
|
export declare function floatFixed(num: string, size?: number): string;
|
|
122
122
|
/**
|
|
123
123
|
* @method cancelBubble
|
|
124
124
|
* @description 阻止冒泡。
|
|
125
|
-
|
|
125
|
+
*/
|
|
126
126
|
export declare function cancelBubble(e: any): void;
|
|
127
127
|
/**
|
|
128
128
|
* @method hasClass
|
|
129
|
-
|
|
129
|
+
*/
|
|
130
130
|
export declare function hasClass(obj: any, cls: string): boolean;
|
|
131
131
|
/**
|
|
132
132
|
* @method addClass
|
|
133
|
-
|
|
133
|
+
*/
|
|
134
134
|
export declare function addClass(obj: any, cls: string): void;
|
|
135
135
|
/**
|
|
136
136
|
* @method removeClass
|
|
137
|
-
|
|
137
|
+
*/
|
|
138
138
|
export declare function removeClass(obj: any, cls: string): void;
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
* EN: Throttle
|
|
141
|
+
* ZH: 节流
|
|
142
|
+
*
|
|
143
|
+
* @see https://lodash.com/docs/4.17.15#throttle
|
|
144
|
+
*/
|
|
145
|
+
export declare function throttle(func: any, wait: number, options?: {
|
|
146
|
+
leading?: boolean;
|
|
147
|
+
trailing?: boolean;
|
|
148
|
+
}): any;
|
|
149
|
+
/**
|
|
150
|
+
* EN: Debounce
|
|
151
|
+
*
|
|
152
|
+
* ZH: 去抖
|
|
153
|
+
*/
|
|
154
|
+
export declare function debounce(func: any, wait: number, immediate?: any): any;
|
|
149
155
|
/**
|
|
150
156
|
* @method friendlyInterval
|
|
151
157
|
* @description 获取间隔时间。
|
|
152
158
|
* @param {number/Date} start 开始时间戳 1585325367122
|
|
153
159
|
* @param {number/Date} end 结束时间戳 1585325367122
|
|
154
|
-
* @
|
|
155
|
-
* @
|
|
156
|
-
|
|
157
|
-
export declare function friendlyInterval(start?: number, end?: number,
|
|
158
|
-
type?: string
|
|
160
|
+
* @param {string} options.type 返回类型 d: 2(天) text: 2 天 4 时...
|
|
161
|
+
* @returns {String/number} 取决于 type
|
|
162
|
+
*/
|
|
163
|
+
export declare function friendlyInterval(start?: number, end?: number, options?: {
|
|
164
|
+
type?: string;
|
|
159
165
|
}): number | string;
|
|
160
166
|
/**
|
|
161
167
|
* @method isNumber
|
|
162
168
|
* @description 判断是否有效数字
|
|
163
169
|
* @param {*} num 被判断的值
|
|
164
|
-
* @param {boolean} isNaNAsNumber 是否 NaN 算数字(默认不算)
|
|
165
|
-
* @param {boolean} isUnFiniteAsNumber 是否 无限 算数字(默认不算)
|
|
166
|
-
* @
|
|
170
|
+
* @param {boolean} options.isNaNAsNumber 是否 NaN 算数字(默认不算)
|
|
171
|
+
* @param {boolean} options.isUnFiniteAsNumber 是否 无限 算数字(默认不算)
|
|
172
|
+
* @returns {boolean} true 是数字
|
|
167
173
|
*/
|
|
168
|
-
export declare function isNumber(num: any,
|
|
169
|
-
isNaNAsNumber?: boolean
|
|
170
|
-
isUnFiniteAsNumber?: boolean
|
|
174
|
+
export declare function isNumber(num: any, options?: {
|
|
175
|
+
isNaNAsNumber?: boolean;
|
|
176
|
+
isUnFiniteAsNumber?: boolean;
|
|
171
177
|
}): boolean;
|
|
172
178
|
/**
|
|
173
179
|
* @method doFn
|
|
174
180
|
* @description 执行有效函数
|
|
175
181
|
* @param {function} fn 等待被执行的未知是否有效的函数
|
|
176
|
-
|
|
182
|
+
*/
|
|
177
183
|
export declare function doFn(fn: any, ...params: any[]): any;
|
|
178
184
|
/**
|
|
179
185
|
* @method setSessionStorage
|
|
180
186
|
* @description 存储数据到 sessionStorage
|
|
181
187
|
* @param {string} key 键
|
|
182
188
|
* @param {string} value 值
|
|
183
|
-
|
|
189
|
+
*/
|
|
184
190
|
export declare function setSessionStorage(key: string, value?: any): void;
|
|
185
191
|
/**
|
|
186
192
|
* @method getSessionStorage
|
|
187
193
|
* @description 存储数据到 sessionStorage
|
|
188
194
|
* @param {string} key 键
|
|
189
|
-
* @
|
|
190
|
-
|
|
195
|
+
* @returns {*} 返回值
|
|
196
|
+
*/
|
|
191
197
|
export declare function getSessionStorage(key: string): any;
|
|
192
198
|
/**
|
|
193
199
|
* @method setLocalStorage
|
|
194
200
|
* @description 存储数据到 localStorage
|
|
195
201
|
* @param {string} key 键
|
|
196
202
|
* @param {string} value 值
|
|
197
|
-
|
|
203
|
+
*/
|
|
198
204
|
export declare function setLocalStorage(key: string, value?: any): void;
|
|
199
205
|
/**
|
|
200
206
|
* @method getLocalStorage
|
|
201
207
|
* @description 存储数据到 localStorage
|
|
202
208
|
* @param {string} key 键
|
|
203
|
-
* @
|
|
204
|
-
|
|
209
|
+
* @returns {*} 返回值
|
|
210
|
+
*/
|
|
205
211
|
export declare function getLocalStorage(key: string): any;
|
|
206
212
|
/**
|
|
207
213
|
* @method loadCSS
|
|
208
214
|
* @description 动态加载css文件
|
|
209
215
|
* @param {string} url -- css资源路径
|
|
210
|
-
* @param {string} id -- link标签id
|
|
211
|
-
* @
|
|
216
|
+
* @param {string} options.id -- link标签id
|
|
217
|
+
* @returns {Promise<boolean>} true -- 加载成功
|
|
212
218
|
*/
|
|
213
|
-
export declare function loadCSS(url
|
|
214
|
-
id?: string
|
|
215
|
-
}): Promise<any>;
|
|
219
|
+
export declare function loadCSS(url: string, options?: {
|
|
220
|
+
id?: string;
|
|
221
|
+
}): Promise<boolean | Error | any>;
|
|
216
222
|
/**
|
|
217
223
|
* @method loadScript
|
|
218
224
|
* @description 动态加载js文件
|
|
219
225
|
* @param {string} url -- js资源路径
|
|
220
|
-
* @param {string} id -- DOM ID
|
|
221
|
-
* @param {function} callback -- 加载后回调函数
|
|
222
|
-
* @param {number} timeout -- 超时时长
|
|
223
|
-
* @param {boolean} isDefer -- 是否添加 defer 标签
|
|
224
|
-
* @
|
|
225
|
-
*/
|
|
226
|
-
export declare function loadScript(url
|
|
227
|
-
id
|
|
228
|
-
callback
|
|
229
|
-
timeout
|
|
230
|
-
isDefer
|
|
231
|
-
}): Promise<
|
|
226
|
+
* @param {string} options.id -- DOM ID
|
|
227
|
+
* @param {function} options.callback -- 加载后回调函数
|
|
228
|
+
* @param {number} options.timeout -- 超时时长
|
|
229
|
+
* @param {boolean} options.isDefer -- 是否添加 defer 标签
|
|
230
|
+
* @returns {Promise<boolean>} -- true 成功
|
|
231
|
+
*/
|
|
232
|
+
export declare function loadScript(url: string, options?: {
|
|
233
|
+
id: string;
|
|
234
|
+
callback: (...params: any[]) => any;
|
|
235
|
+
timeout: number;
|
|
236
|
+
isDefer: boolean;
|
|
237
|
+
}): Promise<boolean | string | Error>;
|
|
232
238
|
/**
|
|
233
239
|
* @method mNow
|
|
234
240
|
* @description 获取时间戳
|
|
@@ -244,71 +250,178 @@ export declare function setCookie(name: string, value: string, days: number, dom
|
|
|
244
250
|
* @description 获取 Cookie
|
|
245
251
|
*/
|
|
246
252
|
export declare function getCookie(name: string): string;
|
|
253
|
+
interface WebPerformance {
|
|
254
|
+
[key: string]: string | number;
|
|
255
|
+
}
|
|
247
256
|
/**
|
|
248
257
|
* @method getPerformance
|
|
249
258
|
* @description 获取页面加载相关的各项数据
|
|
250
259
|
* @param {boolean} camelCase -- true(默认) 以驼峰形式返回数据 false 以下划线形式返回数据
|
|
251
|
-
* @
|
|
260
|
+
* @returns {Promise<object>} 加载数据
|
|
252
261
|
*/
|
|
253
|
-
export declare function getPerformance(camelCase?: boolean): Promise<
|
|
262
|
+
export declare function getPerformance(camelCase?: boolean): Promise<WebPerformance | Error>;
|
|
254
263
|
/**
|
|
255
264
|
* @method inRate
|
|
256
265
|
* @description 百分位概率
|
|
257
266
|
* @param {number} rate -- 0.1 ~ 1 => 1% ~ 100%
|
|
258
|
-
* @
|
|
267
|
+
* @returns {boolean} true 命中
|
|
259
268
|
*/
|
|
260
269
|
export declare function inRate(rate: number): boolean;
|
|
261
270
|
/**
|
|
262
271
|
* @method isSafePWAEnv
|
|
263
272
|
* @description 判断是否是安全的 PWA 环境
|
|
264
|
-
* @
|
|
273
|
+
* @returns {boolean} true 是
|
|
265
274
|
*/
|
|
266
275
|
export declare function isSafePWAEnv(): boolean;
|
|
267
276
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
277
|
+
* EN: Browser Information
|
|
278
|
+
*
|
|
279
|
+
* ZH: 返回浏览器信息 https://github.com/JowayYoung/juejin-code/blob/master/browser-type.js
|
|
280
|
+
*
|
|
281
|
+
* ```
|
|
282
|
+
* getBrowserInfo(); // {"engine":"webkit","engineVs":"537.36","platform":"desktop","supporter":"chrome","supporterVs":"85.0.4183.121","system":"windows","systemVs":"10"}
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* | Index | Field | Description |
|
|
286
|
+
* | --- | --- | --- |
|
|
287
|
+
* | System | system | android, ios, windows, macos, linux |
|
|
288
|
+
* | System version | systemVs | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
|
|
289
|
+
* | Platform | platform | desktop, mobile |
|
|
290
|
+
* | Engine | engine | webkit, gecko, presto, trident |
|
|
291
|
+
* | Engine version | engineVs | - |
|
|
292
|
+
* | Supporter | supporter | edge, opera, chrome, safari, firefox, iexplore |
|
|
293
|
+
* | Supporter version | supporterVs | - |
|
|
294
|
+
* | Shell | shell | (Optional) wechat, qq_browser, qq_app, uc, 360, 2345, sougou, liebao, maxthon, bilibili |
|
|
295
|
+
* | Shell version | shellVs | (Optional) |
|
|
296
|
+
* | Apple device type | appleType | (Optional) iphone, ipad, ipod, iwatch |
|
|
297
|
+
*
|
|
298
|
+
* Example: Determine the environment of the mobile QQ.
|
|
299
|
+
*
|
|
300
|
+
* ```
|
|
301
|
+
* const { system, shell } = getBrowserInfo();
|
|
302
|
+
* const isMobileQQ = ['android', 'ios'].includes(system) && ['qq_browser', 'qq_app'].includes(shell);
|
|
303
|
+
* ```
|
|
304
|
+
*
|
|
305
|
+
* @returns 浏览器信息
|
|
271
306
|
*/
|
|
272
|
-
export declare function getBrowserInfo():
|
|
307
|
+
export declare function getBrowserInfo(): {
|
|
308
|
+
engine: string;
|
|
309
|
+
engineVs: string;
|
|
310
|
+
platform: string;
|
|
311
|
+
supporter: string;
|
|
312
|
+
supporterVs: string;
|
|
313
|
+
system: string;
|
|
314
|
+
systemVs: string;
|
|
315
|
+
shell?: string;
|
|
316
|
+
shellVs?: string;
|
|
317
|
+
appleType?: string;
|
|
318
|
+
};
|
|
273
319
|
/**
|
|
274
320
|
* @method clearHtml
|
|
275
321
|
* @description 去除HTML标签
|
|
276
|
-
* @param {string}
|
|
277
|
-
* @
|
|
322
|
+
* @param {string} str 带html标签的字符串
|
|
323
|
+
* @returns {string} 字符串
|
|
278
324
|
*/
|
|
279
|
-
export declare function clearHtml(
|
|
325
|
+
export declare function clearHtml(str: string): string;
|
|
280
326
|
/**
|
|
281
327
|
* @method cutCHSString
|
|
282
328
|
* @description 截取字符串,中文算2个字节
|
|
283
329
|
* @param {string} str 要截取的字符串
|
|
284
330
|
* @param {number} len
|
|
285
331
|
* @param {boolean} hasDot
|
|
286
|
-
* @
|
|
332
|
+
* @returnss {string} 返回截取后的字符串
|
|
287
333
|
*/
|
|
288
|
-
export declare function cutCHSString(str
|
|
334
|
+
export declare function cutCHSString(str: string, len: number, hasDot?: boolean): string;
|
|
289
335
|
/**
|
|
290
336
|
* @method windowLoaded
|
|
291
337
|
* @description 页面加载完成
|
|
292
338
|
* @param {number} timeout 超时时间 / 单位:秒
|
|
293
|
-
* @
|
|
294
|
-
*/
|
|
295
|
-
export declare function windowLoaded(timeout?: number): Promise<string>;
|
|
296
|
-
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
339
|
+
* @returns {Promise<string>} document is loaded? 'complete' 'load' / 'timeout'
|
|
340
|
+
*/
|
|
341
|
+
export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
342
|
+
/**
|
|
343
|
+
* EN: Add `<style>` in `<head>`.
|
|
344
|
+
*
|
|
345
|
+
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回: 添加成功/失败.
|
|
346
|
+
*
|
|
347
|
+
* Example 1: Add the `<style>` with `id`, and repeated invoking will update the content instead of adding a new one.
|
|
348
|
+
*
|
|
349
|
+
* ```
|
|
350
|
+
* addStyle(
|
|
351
|
+
* `
|
|
352
|
+
* body {
|
|
353
|
+
* background-color: #333;
|
|
354
|
+
* }
|
|
355
|
+
* `,
|
|
356
|
+
* {
|
|
357
|
+
* id: 'test',
|
|
358
|
+
* }
|
|
359
|
+
* );
|
|
360
|
+
* // <style id="test">
|
|
361
|
+
* // body {
|
|
362
|
+
* // background-color: #333;
|
|
363
|
+
* // }
|
|
364
|
+
* // </style>
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* Example 2: Add the `<style>` without `id`, and repeated invoking will adding a new one.
|
|
368
|
+
*
|
|
369
|
+
* ```
|
|
370
|
+
* addStyle(
|
|
371
|
+
* `
|
|
372
|
+
* body {
|
|
373
|
+
* background-color: #333;
|
|
374
|
+
* }
|
|
375
|
+
* `
|
|
376
|
+
* );
|
|
377
|
+
* // <style>
|
|
378
|
+
* // body {
|
|
379
|
+
* // background-color: #333;
|
|
380
|
+
* // }
|
|
381
|
+
* // </style>
|
|
382
|
+
* ```
|
|
383
|
+
*
|
|
384
|
+
* @param style Style string.
|
|
385
|
+
* @param options.id `id` in `<style>`
|
|
386
|
+
* @returns Success/Fail
|
|
387
|
+
*/
|
|
388
|
+
export declare function addStyle(style: string, options?: {
|
|
389
|
+
id?: string;
|
|
305
390
|
}): boolean;
|
|
306
391
|
/**
|
|
307
392
|
* @method genCustomConsole
|
|
308
393
|
* @description 生成自定义控制台打印
|
|
309
394
|
* @param {string} prefix 前缀
|
|
310
395
|
* @param {function} allowFn 允许打印的判断函数
|
|
311
|
-
* @
|
|
312
|
-
*/
|
|
313
|
-
export declare function genCustomConsole(prefix?: string):
|
|
396
|
+
* @returns {object} 新实例
|
|
397
|
+
*/
|
|
398
|
+
export declare function genCustomConsole(prefix?: string): Console;
|
|
399
|
+
/**
|
|
400
|
+
* Verify the validity of axios response.
|
|
401
|
+
*/
|
|
402
|
+
export declare function zAxiosIsValidRes(res: any, options?: {
|
|
403
|
+
validStatus: number[];
|
|
404
|
+
validCode: number[];
|
|
405
|
+
}): boolean;
|
|
406
|
+
/**
|
|
407
|
+
* Verify the validity of a non-empty array.
|
|
408
|
+
*/
|
|
409
|
+
export declare function isNonEmptyArray(arr: any[]): boolean;
|
|
410
|
+
/**
|
|
411
|
+
* 语义化文件大小, 把字节转换成正常文件大小.
|
|
412
|
+
*/
|
|
413
|
+
export declare function getFileSize(size: number): string;
|
|
414
|
+
/**
|
|
415
|
+
* Detect webp support.
|
|
416
|
+
*
|
|
417
|
+
* @see https://davidwalsh.name/detect-webp
|
|
418
|
+
*/
|
|
419
|
+
export declare function isSupportWebp(): Promise<boolean>;
|
|
420
|
+
/**
|
|
421
|
+
* Generate a Hash Code from a string.
|
|
422
|
+
*
|
|
423
|
+
* @see https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery
|
|
424
|
+
*/
|
|
425
|
+
export declare function genHashCode(str: string): number;
|
|
426
|
+
export {};
|
|
314
427
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB5E;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA8B9E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAmBzE;AAED;;;;;;;GAOG;AACF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQnF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,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