mazey 2.0.0 → 2.1.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/src/index.ts CHANGED
@@ -1,11 +1,11 @@
1
- /* Deal */
1
+ /* Mazey */
2
2
 
3
3
  /**
4
4
  * @method calLongestCommonSubstring
5
- * @description 计算两个字符串的最长公共子串
6
- * @param {String} aStr 字符串
7
- * @param {String} bStr 字符串
8
- * @return {Number} 长度
5
+ * @description Computes the longest common substring of two strings.
6
+ * @param {string} aStr String
7
+ * @param {string} bStr String
8
+ * @return {number} Length
9
9
  */
10
10
  export function calLongestCommonSubstring(aStr = '', bStr = ''): number {
11
11
  const aLen = aStr.length;
@@ -33,9 +33,9 @@ export function calLongestCommonSubstring(aStr = '', bStr = ''): number {
33
33
  /**
34
34
  * @method calLongestCommonSubsequence
35
35
  * @description 计算两个字符串的最长公共子序列
36
- * @param {String} aStr 字符串
37
- * @param {String} bStr 字符串
38
- * @return {Number} 长度
36
+ * @param {string} aStr 字符串
37
+ * @param {string} bStr 字符串
38
+ * @return {number} 长度
39
39
  */
40
40
  export function calLongestCommonSubsequence(aStr = '', bStr = ''): number {
41
41
  const aLen = aStr.length;
@@ -72,8 +72,8 @@ export function calLongestCommonSubsequence(aStr = '', bStr = ''): number {
72
72
  /**
73
73
  * @method getQueryParam
74
74
  * @description Get the query param's value of the current Web URL(`location.search`).
75
- * @param {String} param Query param.
76
- * @return {String} value
75
+ * @param {string} param Query param.
76
+ * @return {string} value
77
77
  * */
78
78
  export function getQueryParam(param = ''): string {
79
79
  const reg = new RegExp('(^|&)' + param + '=([^&]*)(&|$)');
@@ -87,9 +87,9 @@ export function getQueryParam(param = ''): string {
87
87
  /**
88
88
  * @method getUrlParam
89
89
  * @description Get the query param's value of the input URL.
90
- * @param {String} url URL string.
91
- * @param {String} param Query param.
92
- * @return {String} value
90
+ * @param {string} url URL string.
91
+ * @param {string} param Query param.
92
+ * @return {string} value
93
93
  * */
94
94
  export function getUrlParam(url = '', param = ''): string {
95
95
  const result: any = {};
@@ -113,10 +113,10 @@ export function getUrlParam(url = '', param = ''): string {
113
113
  /**
114
114
  * @method updateQueryParam
115
115
  * @description Update the query param's value of the input URL.
116
- * @param {String} url URL string.
117
- * @param {String} param Query param.
118
- * @param {String} value Param's value.
119
- * @return {String} URL.
116
+ * @param {string} url URL string.
117
+ * @param {string} param Query param.
118
+ * @param {string} value Param's value.
119
+ * @return {string} URL.
120
120
  * */
121
121
  export function updateQueryParam(url = '', param = '', value = ''): string {
122
122
  const re = new RegExp('([?&])' + param + '=.*?(&|$)', 'i');
@@ -131,8 +131,8 @@ export function getUrlParam(url = '', param = ''): string {
131
131
  /**
132
132
  * @method getHashQueryParam
133
133
  * @description Get the hash query param's value of the current Web URL(`location.hash`).
134
- * @param {String} param Query param.
135
- * @return {String} value
134
+ * @param {string} param Query param.
135
+ * @return {string} value
136
136
  */
137
137
  export function getHashQueryParam(param = ''): string {
138
138
  const hashs = location.hash.split('?');
@@ -147,8 +147,8 @@ export function getHashQueryParam(param = ''): string {
147
147
  /**
148
148
  * @method getDomain
149
149
  * @description Get the domain of URL, and other params.
150
- * @param {String} url
151
- * @param {Array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
150
+ * @param {string} url
151
+ * @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
152
152
  * */
153
153
  export function getDomain(url = '', rules = ['hostname']): string {
154
154
  const aEl: any = document.createElement('a');
@@ -162,8 +162,8 @@ export function getDomain(url = '', rules = ['hostname']): string {
162
162
  /**
163
163
  * @method camelCaseToKebabCase
164
164
  * @description Transfer CamelCase to KebabCase.
165
- * @param {String} camelCase 'aBC' or 'ABC'
166
- * @return {String} 'a-b-c'
165
+ * @param {string} camelCase 'aBC' or 'ABC'
166
+ * @return {string} 'a-b-c'
167
167
  * */
168
168
  export function camelCaseToKebabCase(camelCase = ''): string {
169
169
  const kebabCase = camelCase.replace(/([A-Z])/g, '-$1').toLowerCase();
@@ -173,8 +173,8 @@ export function camelCaseToKebabCase(camelCase = ''): string {
173
173
  /**
174
174
  * @method camelCase2Underscore
175
175
  * @description Transfer CamelCase to Underscore.
176
- * @param {String} camelCase 'aBC' or 'ABC'
177
- * @return {String} 'a_b_c'
176
+ * @param {string} camelCase 'aBC' or 'ABC'
177
+ * @return {string} 'a_b_c'
178
178
  * */
179
179
  export function camelCase2Underscore(camelCase = ''): string {
180
180
  const kebabCase = camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();
@@ -184,8 +184,8 @@ export function camelCase2Underscore(camelCase = ''): string {
184
184
  /**
185
185
  * @method mTrim
186
186
  * @description Remove leading and trailing whitespace or specified characters from string.
187
- * @param {String} str The string to trim.
188
- * @return {String} Trimmed string.
187
+ * @param {string} str The string to trim.
188
+ * @return {string} Trimmed string.
189
189
  * */
190
190
  export function mTrim(str = ''): string {
191
191
  str = str.replace(/^\s+/, ''); // 去除头部空格
@@ -200,8 +200,8 @@ export function mTrim(str = ''): string {
200
200
  /**
201
201
  * @method newLine
202
202
  * @description Make a newline of HTML.
203
- * @param {String} str The string to make a newline.
204
- * @return {String} A newline with `<br />`.
203
+ * @param {string} str The string to make a newline.
204
+ * @return {string} A newline with `<br />`.
205
205
  * */
206
206
  export function newLine(str = ''): string {
207
207
  if (!str) {
@@ -214,8 +214,8 @@ export function newLine(str = ''): string {
214
214
  /**
215
215
  * @method deepCopyObject
216
216
  * @description Clone Object deeply.
217
- * @param {Object} obj The value to clone.
218
- * @return {Object} Returns the deep cloned value.
217
+ * @param {object} obj The value to clone.
218
+ * @return {object} Returns the deep cloned value.
219
219
  * */
220
220
  export function deepCopyObject(obj: any): any {
221
221
  return JSON.parse(JSON.stringify(obj));
@@ -224,8 +224,8 @@ export function deepCopyObject(obj: any): any {
224
224
  /**
225
225
  * @method isJsonString
226
226
  * @description Check whether it is a valid JSON string.
227
- * @param {String} str The string to check.
228
- * @return {Boolean} Return the result of checking.
227
+ * @param {string} str The string to check.
228
+ * @return {boolean} Return the result of checking.
229
229
  * */
230
230
  export function isJsonString(str = ''): boolean {
231
231
  try {
@@ -241,8 +241,8 @@ export function isJsonString(str = ''): boolean {
241
241
  /**
242
242
  * @method generateRndNum
243
243
  * @description Produce a random string of number, `generateRndNum(7)` => '7658495'.
244
- * @param {Number} n Length
245
- * @return {String} Return the random string.
244
+ * @param {number} n Length
245
+ * @return {string} Return the random string.
246
246
  * */
247
247
  export function generateRndNum(n = 5): string {
248
248
  let ret = '';
@@ -255,7 +255,7 @@ export function generateRndNum(n = 5): string {
255
255
  /**
256
256
  * @method generateUniqueNum
257
257
  * @description 根据时间生成唯一标志的数字 mGenerateUniqueNum() => 1538324722364123。
258
- * @param {Number} n 随机数的长度
258
+ * @param {number} n 随机数的长度
259
259
  * */
260
260
  export function generateUniqueNum(n = 3): string {
261
261
  const [now, rnd] = [mNow(), generateRndNum(n || 3)];
@@ -265,8 +265,8 @@ export function generateUniqueNum(n = 3): string {
265
265
  /**
266
266
  * @method floatToPercent
267
267
  * @description 浮点数转为百分比 0.2 => 20%。
268
- * @param {Number} num 浮点数
269
- * @param {Number} fixSize 保留几位浮点数
268
+ * @param {number} num 浮点数
269
+ * @param {number} fixSize 保留几位浮点数
270
270
  * */
271
271
  export function floatToPercent(num = 0, fixSize = 0): string {
272
272
  let ret = '';
@@ -432,10 +432,10 @@ export function debounce(func: any, wait: number, immediate: any): any {
432
432
  /**
433
433
  * @method friendlyInterval
434
434
  * @description 获取间隔时间。
435
- * @param {Number/Date} start 开始时间戳 1585325367122
436
- * @param {Number/Date} end 结束时间戳 1585325367122
437
- * @type {String} type 返回类型 d: 2(天) text: 2 天 4 时...
438
- * @return {String/Number} 取决于 type
435
+ * @param {number/Date} start 开始时间戳 1585325367122
436
+ * @param {number/Date} end 结束时间戳 1585325367122
437
+ * @type {string} type 返回类型 d: 2(天) text: 2 天 4 时...
438
+ * @return {String/number} 取决于 type
439
439
  * */
440
440
  export function friendlyInterval({ start = 0, end = 0, type = 'd' } = {}): number | string {
441
441
  if (!isNumber(start)) start = new Date(start).getTime();
@@ -470,9 +470,9 @@ export function friendlyInterval({ start = 0, end = 0, type = 'd' } = {}): numbe
470
470
  * @method isNumber
471
471
  * @description 判断是否有效数字
472
472
  * @param {*} num 被判断的值
473
- * @param {Boolean} isNaNAsNumber 是否 NaN 算数字(默认不算)
474
- * @param {Boolean} isUnFiniteAsNumber 是否 无限 算数字(默认不算)
475
- * @return {Boolean} true 是数字
473
+ * @param {boolean} isNaNAsNumber 是否 NaN 算数字(默认不算)
474
+ * @param {boolean} isUnFiniteAsNumber 是否 无限 算数字(默认不算)
475
+ * @return {boolean} true 是数字
476
476
  */
477
477
  export function isNumber(num: any, { isNaNAsNumber = false, isUnFiniteAsNumber = false } = {}): boolean {
478
478
  let ret = true;
@@ -496,7 +496,7 @@ export function isNumber(num: any, { isNaNAsNumber = false, isUnFiniteAsNumber =
496
496
  /**
497
497
  * @method doFn
498
498
  * @description 执行有效函数
499
- * @param {Function} fn 等待被执行的未知是否有效的函数
499
+ * @param {function} fn 等待被执行的未知是否有效的函数
500
500
  * */
501
501
  export function doFn(fn: any, ...params: any[]): any {
502
502
  let ret = null;
@@ -509,8 +509,8 @@ export function doFn(fn: any, ...params: any[]): any {
509
509
  /**
510
510
  * @method setSessionStorage
511
511
  * @description 存储数据到 sessionStorage
512
- * @param {String} key 键
513
- * @param {String} value 值
512
+ * @param {string} key 键
513
+ * @param {string} value 值
514
514
  * */
515
515
  export function setSessionStorage(key: string, value: any = null): void {
516
516
  if (key) {
@@ -521,7 +521,7 @@ export function setSessionStorage(key: string, value: any = null): void {
521
521
  /**
522
522
  * @method getSessionStorage
523
523
  * @description 存储数据到 sessionStorage
524
- * @param {String} key 键
524
+ * @param {string} key 键
525
525
  * @return {*} 返回值
526
526
  * */
527
527
  export function getSessionStorage(key: string): any {
@@ -538,8 +538,8 @@ export function getSessionStorage(key: string): any {
538
538
  /**
539
539
  * @method setLocalStorage
540
540
  * @description 存储数据到 localStorage
541
- * @param {String} key 键
542
- * @param {String} value 值
541
+ * @param {string} key 键
542
+ * @param {string} value 值
543
543
  * */
544
544
  export function setLocalStorage(key: string, value: any = null): void {
545
545
  if (key) {
@@ -550,7 +550,7 @@ export function setLocalStorage(key: string, value: any = null): void {
550
550
  /**
551
551
  * @method getLocalStorage
552
552
  * @description 存储数据到 localStorage
553
- * @param {String} key 键
553
+ * @param {string} key 键
554
554
  * @return {*} 返回值
555
555
  * */
556
556
  export function getLocalStorage(key: string): any {
@@ -567,9 +567,9 @@ export function getLocalStorage(key: string): any {
567
567
  /**
568
568
  * @method loadCSS
569
569
  * @description 动态加载css文件
570
- * @param {String} url -- css资源路径
571
- * @param {String} id -- link标签id
572
- * @return {Promise<Boolean>} true -- 加载成功
570
+ * @param {string} url -- css资源路径
571
+ * @param {string} id -- link标签id
572
+ * @return {Promise<boolean>} true -- 加载成功
573
573
  */
574
574
  export function loadCSS({ url = '', id = '' } = {}): Promise<any> {
575
575
  let success: any = null;
@@ -688,12 +688,12 @@ export function loadCSS({ url = '', id = '' } = {}): Promise<any> {
688
688
  /**
689
689
  * @method loadScript
690
690
  * @description 动态加载js文件
691
- * @param {String} url -- js资源路径
692
- * @param {String} id -- DOM ID
693
- * @param {Function} callback -- 加载后回调函数
694
- * @param {Number} timeout -- 超时时长
695
- * @param {Boolean} isDefer -- 是否添加 defer 标签
696
- * @return {Promise<Boolean>} -- true 成功
691
+ * @param {string} url -- js资源路径
692
+ * @param {string} id -- DOM ID
693
+ * @param {function} callback -- 加载后回调函数
694
+ * @param {number} timeout -- 超时时长
695
+ * @param {boolean} isDefer -- 是否添加 defer 标签
696
+ * @return {Promise<boolean>} -- true 成功
697
697
  */
698
698
  export function loadScript({ url = '', id = '', callback = function () { /* pass */ }, timeout = 5000, isDefer = false } = {}): Promise<any> {
699
699
  let success: any = null;
@@ -810,8 +810,8 @@ export function getCookie(name: string): string {
810
810
  /**
811
811
  * @method getPerformance
812
812
  * @description 获取页面加载相关的各项数据
813
- * @param {Boolean} camelCase -- true(默认) 以驼峰形式返回数据 false 以下划线形式返回数据
814
- * @return {Promise<Object>} 加载数据
813
+ * @param {boolean} camelCase -- true(默认) 以驼峰形式返回数据 false 以下划线形式返回数据
814
+ * @return {Promise<object>} 加载数据
815
815
  */
816
816
  export function getPerformance({ camelCase = true } = {}): Promise<any> {
817
817
  let success: any;
@@ -1020,8 +1020,8 @@ export function getPerformance({ camelCase = true } = {}): Promise<any> {
1020
1020
  /**
1021
1021
  * @method inRate
1022
1022
  * @description 百分位概率
1023
- * @param {Number} rate -- 0.1 ~ 1 => 1% ~ 100%
1024
- * @return {Boolean} true 命中
1023
+ * @param {number} rate -- 0.1 ~ 1 => 1% ~ 100%
1024
+ * @return {boolean} true 命中
1025
1025
  */
1026
1026
  export function inRate(rate: number): boolean {
1027
1027
  if(Math.random() < rate) {
@@ -1033,7 +1033,7 @@ export function inRate(rate: number): boolean {
1033
1033
  /**
1034
1034
  * @method isSafePWAEnv
1035
1035
  * @description 判断是否是安全的 PWA 环境
1036
- * @return {Boolean} true 是
1036
+ * @return {boolean} true 是
1037
1037
  */
1038
1038
  export function isSafePWAEnv(): boolean {
1039
1039
  // 判断是否支持 async await
@@ -1060,7 +1060,7 @@ export function isSafePWAEnv(): boolean {
1060
1060
  return false;
1061
1061
  }
1062
1062
  // 浏览器信息
1063
- const BrowserType = getBrowserType();
1063
+ const BrowserType = getBrowserInfo();
1064
1064
  if (
1065
1065
  ('serviceWorker' in navigator) &&
1066
1066
  isSupportAsyncAwait() &&
@@ -1076,11 +1076,11 @@ export function isSafePWAEnv(): boolean {
1076
1076
  }
1077
1077
 
1078
1078
  /**
1079
- * @method getBrowserType
1079
+ * @method getBrowserInfo
1080
1080
  * @description 返回浏览器信息 https://github.com/JowayYoung/juejin-code/blob/master/browser-type.js
1081
- * @return {Object} 浏览器信息
1081
+ * @return {object} 浏览器信息
1082
1082
  */
1083
- export function getBrowserType(): any {
1083
+ export function getBrowserInfo(): any {
1084
1084
  try {
1085
1085
  // 权重:系统 + 系统版本 > 平台 > 内核 + 载体 + 内核版本 + 载体版本 > 外壳 + 外壳版本
1086
1086
  const ua: any = navigator.userAgent.toLowerCase();
@@ -1090,7 +1090,9 @@ export function getBrowserType(): any {
1090
1090
  .replace(/[^0-9|_.]/g, "")
1091
1091
  .replace(/_/g, ".");
1092
1092
  // 系统
1093
- let system = "unknow";
1093
+ let system = '';
1094
+ // Apple device type.
1095
+ let appleType = '';
1094
1096
  if (testUa(/windows|win32|win64|wow32|wow64/g)) {
1095
1097
  system = "windows"; // windows系统
1096
1098
  } else if (testUa(/macintosh|macintel/g)) {
@@ -1101,9 +1103,18 @@ export function getBrowserType(): any {
1101
1103
  system = "android"; // android系统
1102
1104
  } else if (testUa(/ios|iphone|ipad|ipod|iwatch/g)) {
1103
1105
  system = "ios"; // ios系统
1106
+ if (testUa(/iphone/g)) {
1107
+ appleType = 'iphone';
1108
+ } else if (testUa(/ipad/g)) {
1109
+ appleType = 'ipad';
1110
+ } else if (testUa(/iwatch/g)) {
1111
+ appleType = 'iwatch';
1112
+ } else if (testUa(/ipod/g)) {
1113
+ appleType = 'ipod';
1114
+ }
1104
1115
  }
1105
1116
  // 系统版本
1106
- let systemVs = "unknow";
1117
+ let systemVs = '';
1107
1118
  if (system === "windows") {
1108
1119
  if (testUa(/windows nt 5.0|windows 2000/g)) {
1109
1120
  systemVs = "2000";
@@ -1130,15 +1141,15 @@ export function getBrowserType(): any {
1130
1141
  systemVs = testVs(/os [\d._]+/g);
1131
1142
  }
1132
1143
  // 平台
1133
- let platform = "unknow";
1144
+ let platform = '';
1134
1145
  if (system === "windows" || system === "macos" || system === "linux") {
1135
1146
  platform = "desktop"; // 桌面端
1136
1147
  } else if (system === "android" || system === "ios" || testUa(/mobile/g)) {
1137
1148
  platform = "mobile"; // 移动端
1138
1149
  }
1139
1150
  // 内核和载体
1140
- let engine = "unknow";
1141
- let supporter = "unknow";
1151
+ let engine = '';
1152
+ let supporter = '';
1142
1153
  if (testUa(/applewebkit/g)) {
1143
1154
  engine = "webkit"; // webkit内核
1144
1155
  if (testUa(/edge/g)) {
@@ -1161,7 +1172,7 @@ export function getBrowserType(): any {
1161
1172
  supporter = "iexplore"; // iexplore浏览器
1162
1173
  }
1163
1174
  // 内核版本
1164
- let engineVs = "unknow";
1175
+ let engineVs = '';
1165
1176
  if (engine === "webkit") {
1166
1177
  engineVs = testVs(/applewebkit\/[\d._]+/g);
1167
1178
  } else if (engine === "gecko") {
@@ -1172,7 +1183,7 @@ export function getBrowserType(): any {
1172
1183
  engineVs = testVs(/trident\/[\d._]+/g);
1173
1184
  }
1174
1185
  // 载体版本
1175
- let supporterVs = "unknow";
1186
+ let supporterVs = '';
1176
1187
  if (supporter === "chrome") {
1177
1188
  supporterVs = testVs(/chrome\/[\d._]+/g);
1178
1189
  } else if (supporter === "safari") {
@@ -1187,14 +1198,16 @@ export function getBrowserType(): any {
1187
1198
  supporterVs = testVs(/edge\/[\d._]+/g);
1188
1199
  }
1189
1200
  // 外壳和外壳版本
1190
- let shell = "none";
1191
- let shellVs = "unknow";
1201
+ let shell = '';
1202
+ let shellVs = '';
1192
1203
  if (testUa(/micromessenger/g)) {
1193
1204
  shell = "wechat"; // 微信浏览器
1194
1205
  shellVs = testVs(/micromessenger\/[\d._]+/g);
1195
1206
  } else if (testUa(/qqbrowser/g)) {
1196
- shell = "qq"; // QQ浏览器
1207
+ shell = "qq_browser"; // QQ Browser
1197
1208
  shellVs = testVs(/qqbrowser\/[\d._]+/g);
1209
+ } else if (testUa(/\sqq/g)) {
1210
+ shell = "qq_app"; // QQ APP
1198
1211
  } else if (testUa(/ucbrowser/g)) {
1199
1212
  shell = "uc"; // UC浏览器
1200
1213
  shellVs = testVs(/ucbrowser\/[\d._]+/g);
@@ -1210,6 +1223,8 @@ export function getBrowserType(): any {
1210
1223
  } else if (testUa(/maxthon/g)) {
1211
1224
  shell = "maxthon"; // 遨游浏览器
1212
1225
  shellVs = testVs(/maxthon\/[\d._]+/g);
1226
+ } else if (testUa(/biliapp/g)) {
1227
+ shell = "bilibili"; // 哔哩哔哩
1213
1228
  }
1214
1229
  return Object.assign({
1215
1230
  engine, // webkit gecko presto trident
@@ -1218,10 +1233,11 @@ export function getBrowserType(): any {
1218
1233
  supporter, // chrome safari firefox opera iexplore edge
1219
1234
  supporterVs,
1220
1235
  system, // windows macos linux android ios
1221
- systemVs
1222
- }, shell === "none" ? {} : {
1236
+ systemVs,
1237
+ }, {
1223
1238
  shell, // wechat qq uc 360 2345 sougou liebao maxthon
1224
- shellVs
1239
+ shellVs,
1240
+ appleType,
1225
1241
  });
1226
1242
  } catch (err) {
1227
1243
  return {};
@@ -1231,8 +1247,8 @@ export function getBrowserType(): any {
1231
1247
  /**
1232
1248
  * @method clearHtml
1233
1249
  * @description 去除HTML标签
1234
- * @param {String} string 带html标签的字符串
1235
- * @return {String} 字符串
1250
+ * @param {string} string 带html标签的字符串
1251
+ * @return {string} 字符串
1236
1252
  */
1237
1253
  export function clearHtml (string = ''): string {
1238
1254
  return string.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
@@ -1241,10 +1257,10 @@ export function clearHtml (string = ''): string {
1241
1257
  /**
1242
1258
  * @method cutCHSString
1243
1259
  * @description 截取字符串,中文算2个字节
1244
- * @param {String} str 要截取的字符串
1245
- * @param {Number} len
1246
- * @param {Boolean} hasDot
1247
- * @returns {String} 返回截取后的字符串
1260
+ * @param {string} str 要截取的字符串
1261
+ * @param {number} len
1262
+ * @param {boolean} hasDot
1263
+ * @returns {string} 返回截取后的字符串
1248
1264
  */
1249
1265
  export function cutCHSString(str = '', len = str.length, hasDot = false): string {
1250
1266
  if (str == '' || !str) {
@@ -1279,7 +1295,7 @@ export function cutCHSString(str = '', len = str.length, hasDot = false): string
1279
1295
  /**
1280
1296
  * @method windowLoaded
1281
1297
  * @description 页面加载完成
1282
- * @param {Number} timeout 超时时间 / 单位:秒
1298
+ * @param {number} timeout 超时时间 / 单位:秒
1283
1299
  * @return {Promise<string>} document is loaded? 'complete' 'load' / 'timeout'
1284
1300
  */
1285
1301
  export function windowLoaded({ timeout = 90 } = {}): Promise<string> {
@@ -1302,9 +1318,9 @@ export function windowLoaded({ timeout = 90 } = {}): Promise<string> {
1302
1318
  /**
1303
1319
  * @method addInlineStyle
1304
1320
  * @description 添加内联样式
1305
- * @param {String} inlineStyle 内联样式字符串
1306
- * @param {String} id <style> 标签的 ID
1307
- * @return {Boolean} 添加成功/失败
1321
+ * @param {string} inlineStyle 内联样式字符串
1322
+ * @param {string} id <style> 标签的 ID
1323
+ * @return {boolean} 添加成功/失败
1308
1324
  */
1309
1325
  export function addInlineStyle({ inlineStyle = '', id = '' } = {}): boolean {
1310
1326
  if (!inlineStyle) {
@@ -1340,9 +1356,9 @@ export function addInlineStyle({ inlineStyle = '', id = '' } = {}): boolean {
1340
1356
  /**
1341
1357
  * @method genCustomConsole
1342
1358
  * @description 生成自定义控制台打印
1343
- * @param {String} prefix 前缀
1344
- * @param {Function} allowFn 允许打印的判断函数
1345
- * @return {Object} 新实例
1359
+ * @param {string} prefix 前缀
1360
+ * @param {function} allowFn 允许打印的判断函数
1361
+ * @return {object} 新实例
1346
1362
  */
1347
1363
  export function genCustomConsole({ prefix = '' } = {}): any {
1348
1364
  const methods = ['log', 'info', 'warn', 'error'];
package/tsconfig.json CHANGED
@@ -68,6 +68,7 @@
68
68
  "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
69
69
  },
70
70
  "include": [
71
- "src/**/*.ts"
71
+ // "src/**/*.ts",
72
+ "src/index.ts"
72
73
  ]
73
74
  }
package/typing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  // declare const navigator any;
2
- declare namespace navigator {
3
- let connection: string;
4
- }
2
+ // declare namespace navigator {
3
+ // let connection: string;
4
+ // }
package/lib/example.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=example.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["src/example.ts"],"names":[],"mappings":""}