mazey 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -148
- package/lib/index.cjs.js +39 -2
- package/lib/index.d.ts +34 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +39 -3
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
- package/README_CN.md +0 -361
- package/examples/index.html +0 -21
- package/examples/index.ts +0 -121
- package/images/mazey-v1.4.39.svg +0 -1
- package/src/index.ts +0 -2543
- package/src/preview.js +0 -3
package/README_CN.md
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
⚠️ Note: The document has expired, please check the latest [README.md](./README.md).
|
|
2
|
-
|
|
3
|
-
⚠️ 注意: 此文档只适用于 v1.4.39 版本,[查看 v3.x 版本的文档](./README.md)
|
|
4
|
-
|
|
5
|
-
# mazey
|
|
6
|
-
|
|
7
|
-
[![NPM version][npm-image]][npm-url]
|
|
8
|
-
[![l][l-image]][l-url]
|
|
9
|
-
|
|
10
|
-
[npm-image]: ./images/mazey-v1.4.39.svg
|
|
11
|
-
[npm-url]: https://www.npmjs.com/package/mazey/v/1.4.39
|
|
12
|
-
[l-image]: https://img.shields.io/npm/l/mazey
|
|
13
|
-
[l-url]: https://github.com/mazeyqian/mazey
|
|
14
|
-
|
|
15
|
-
后除的 JavaScript 函数库,所有的方法都在线上项目中使用过
|
|
16
|
-
|
|
17
|
-
**目录**
|
|
18
|
-
|
|
19
|
-
- [mazey](#mazey)
|
|
20
|
-
- [安装](#安装)
|
|
21
|
-
- [使用](#使用)
|
|
22
|
-
- [加载资源](#加载资源)
|
|
23
|
-
- [存储数据](#存储数据)
|
|
24
|
-
- [操作 DOM](#操作-dom)
|
|
25
|
-
- [网站性能](#网站性能)
|
|
26
|
-
- [公式计算](#公式计算)
|
|
27
|
-
- [浏览器信息](#浏览器信息)
|
|
28
|
-
- [安全边际](#安全边际)
|
|
29
|
-
- [函数](#函数)
|
|
30
|
-
- [调试](#调试)
|
|
31
|
-
- [开发](#开发)
|
|
32
|
-
- [参考](#参考)
|
|
33
|
-
|
|
34
|
-
## 安装
|
|
35
|
-
|
|
36
|
-
使用 [NPM](https://www.npmjs.com/package/mazey/v/1.4.39) 安装 mazey@1.4.39
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
npm install mazey@1.4.39 --save
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## 使用
|
|
43
|
-
|
|
44
|
-
### 加载资源
|
|
45
|
-
|
|
46
|
-
加载 JavaScript
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
import { loadScript } from 'mazey';
|
|
50
|
-
|
|
51
|
-
loadScript({
|
|
52
|
-
url: 'http://www.mazey.net/js/plugin/jquery/jquery-2.1.1.min.js',
|
|
53
|
-
id: 'iamid', // 可选,script 标签 ID,默认无 ID
|
|
54
|
-
timeout: 5000, // 可选,超时时间,默认 5000
|
|
55
|
-
isDefer: false, // 可选,defer,默认 false
|
|
56
|
-
})
|
|
57
|
-
.then(
|
|
58
|
-
res => {
|
|
59
|
-
console.log(`加载 JavaScript 成功: ${res}`);
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
.catch(
|
|
63
|
-
err => {
|
|
64
|
-
console.error(`加载 JavaScript 失败: ${err}`)
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
加载 CSS
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
import { loadCSS } from 'mazey';
|
|
73
|
-
|
|
74
|
-
loadCSS({
|
|
75
|
-
url: 'http://www.mazey.net/css/mazey-base.css',
|
|
76
|
-
id: 'iamid', // 可选,link 标签 ID,默认无 ID
|
|
77
|
-
})
|
|
78
|
-
.then(
|
|
79
|
-
res => {
|
|
80
|
-
console.log(`加载 CSS 成功: ${res}`);
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
.catch(
|
|
84
|
-
err => {
|
|
85
|
-
console.error(`加载 CSS 失败: ${err}`)
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
判断页面是否加载完成(兼容浏览器 `load` 事件已经触发过的情况)
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
import { loadCSS } from 'mazey';
|
|
94
|
-
|
|
95
|
-
windowLoaded({ timeout: 30 })
|
|
96
|
-
.then(res => {
|
|
97
|
-
console.log(`加载完成:${res}`); // 加载完成:load
|
|
98
|
-
})
|
|
99
|
-
.catch(err => {
|
|
100
|
-
console.log(`加载超时或失败:${err}`);
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### 存储数据
|
|
105
|
-
|
|
106
|
-
Storage(兼容 JSON 格式,自行转换)
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from 'mazey';
|
|
110
|
-
|
|
111
|
-
setSessionStorage('test', '123');
|
|
112
|
-
getSessionStorage('test'); // 123
|
|
113
|
-
setLocalStorage('test', '123');
|
|
114
|
-
getLocalStorage('test'); // 123
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Cookie
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
import { setCookie, getCookie } from 'mazey';
|
|
121
|
-
|
|
122
|
-
setCookie('test', '123', 30, 'mazey.net'); // key value day domain
|
|
123
|
-
getCookie('test'); // 123
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### 操作 DOM
|
|
127
|
-
|
|
128
|
-
修改 `class`
|
|
129
|
-
|
|
130
|
-
```
|
|
131
|
-
import { hasClass, addClass, removeClass } from 'mazey';
|
|
132
|
-
|
|
133
|
-
const dom = document.querySelector('#box');
|
|
134
|
-
|
|
135
|
-
// 判断 class
|
|
136
|
-
hasClass(dom, 'test');
|
|
137
|
-
// 增加 class
|
|
138
|
-
addClass(dom, 'test');
|
|
139
|
-
// 删除 class
|
|
140
|
-
removeClass(dom, 'test');
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
添加内联样式
|
|
144
|
-
|
|
145
|
-
```
|
|
146
|
-
import { addInlineStyle } from 'mazey';
|
|
147
|
-
|
|
148
|
-
// 添加有 id 的内联样式,重复添加会更新内联样式而不是新增
|
|
149
|
-
addInlineStyle({
|
|
150
|
-
inlineStyle: `
|
|
151
|
-
body {
|
|
152
|
-
background-color: #333;
|
|
153
|
-
}
|
|
154
|
-
`,
|
|
155
|
-
id: 'test',
|
|
156
|
-
});
|
|
157
|
-
// <style id="test">
|
|
158
|
-
// body {
|
|
159
|
-
// background-color: #333;
|
|
160
|
-
// }
|
|
161
|
-
// </style>
|
|
162
|
-
|
|
163
|
-
// 添加无 id 的内联样式,重复添加会新增内联样式
|
|
164
|
-
addInlineStyle({
|
|
165
|
-
inlineStyle: `
|
|
166
|
-
body {
|
|
167
|
-
background-color: #444;
|
|
168
|
-
}
|
|
169
|
-
`,
|
|
170
|
-
});
|
|
171
|
-
// <style>
|
|
172
|
-
// body {
|
|
173
|
-
// background-color: #444;
|
|
174
|
-
// }
|
|
175
|
-
// </style>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
添加自定义滚动条(适用于用 `transform` 移动的元素)
|
|
179
|
-
|
|
180
|
-
```
|
|
181
|
-
import { customScrollBarForTransformEle } from 'mazey';
|
|
182
|
-
|
|
183
|
-
// 使用类名
|
|
184
|
-
customScrollBarForTransformEle({
|
|
185
|
-
containerClassName: 'i-am-container',
|
|
186
|
-
imgBoxClassName: 'i-am-img-father-i-can-transform',
|
|
187
|
-
imgClassName: 'i-am-img',
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
// 使用 Dom 对象
|
|
191
|
-
customScrollBarForTransformEle({
|
|
192
|
-
containerClassName: 'i-am-container',
|
|
193
|
-
imgBoxDom: document.querySelector('.i-am-img-father-i-can-transform'),
|
|
194
|
-
imgDom: document.querySelector('.i-am-img-father-i-can-transform'),
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// 按需直接隐藏滚动条
|
|
198
|
-
customScrollBarForTransformEle({
|
|
199
|
-
containerClassName: 'i-am-container',
|
|
200
|
-
action: 'hide',
|
|
201
|
-
});
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
计算适配容器宽度的图片的尺寸、距离顶部的距离
|
|
205
|
-
|
|
206
|
-
```
|
|
207
|
-
import { calcContainImageSizeAndPosition } from 'mazey';
|
|
208
|
-
|
|
209
|
-
// 如果高度不足以占满容器,使其垂直居中;如果高度比容器长,由上向下铺开
|
|
210
|
-
calcContainImageSizeAndPosition({ oriImageWidth: 300, oriImageHeight: 300, viewportWidth: 375, viewportHeight: 812 });
|
|
211
|
-
// {"targetImageWidth":375,"targetImageHeight":375,"top":218.5,"wPer":1.25}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### 网站性能
|
|
215
|
-
|
|
216
|
-
获取加载时间
|
|
217
|
-
|
|
218
|
-
```
|
|
219
|
-
import { getPerformance } from 'mazey';
|
|
220
|
-
|
|
221
|
-
// camelCase:true(默认) 以驼峰形式返回数据 / false 以下划线形式返回数据
|
|
222
|
-
getPerformance({ camelCase: true })
|
|
223
|
-
.then(res => {
|
|
224
|
-
console.log(JSON.stringify(res));
|
|
225
|
-
// {"deviceType":"pc","network":"3g","unloadTime":0,"redirectTime":0,"dnsTime":0,"tcpTime":0,"responseTime":65,"downloadTime":1,"domreadyTime":369,"onloadTime":441,"whiteTime":94,"renderTime":441,"decodedBodySize":210,"encodedBodySize":210}
|
|
226
|
-
})
|
|
227
|
-
.catch(console.error);
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
| 指标 | 字段 | 计算⽅法 |
|
|
231
|
-
| --- | --- | --- |
|
|
232
|
-
| * DNS 查询时间 | dns_time | domainLookupEnd - domainLookupStart |
|
|
233
|
-
| * 服务器连接时间 | tcp_time | connectEnd - connectStart |
|
|
234
|
-
| * 服务器响应时间 | response_time | responseStart - requestStart |
|
|
235
|
-
| * ⽩屏时间 | white_time | responseStart - navigationStart |
|
|
236
|
-
| * DomReady 总时间 | domready_time | domContentLoadedEventStart - navigationStart |
|
|
237
|
-
| * 页面加载时间 | onload_time | loadEventStart - navigationStart |
|
|
238
|
-
| * EventEnd 总时间 | render_time | loadEventEnd -navigationStart |
|
|
239
|
-
| 上个⽂档卸载时间 | unload_time | unloadEventEnd - unloadEventStart |
|
|
240
|
-
| 重定向时间 | redirect_time | redirectEnd - redirectStart |
|
|
241
|
-
| 客户端⽩屏时间 | custom_white_time | renderTiming - navigationStart |
|
|
242
|
-
| SSL连接时间 | ssl_time | connectEnd - secureConnectionStart |
|
|
243
|
-
| ⽹⻚下载时间 | download_time | responseEnd - responseStart |
|
|
244
|
-
| FCP | first_contentful_paint_time | firstPaintTime |
|
|
245
|
-
|
|
246
|
-
### 公式计算
|
|
247
|
-
|
|
248
|
-
计算两个字符串的最长公共子串
|
|
249
|
-
|
|
250
|
-
```
|
|
251
|
-
import { calLongestCommonSubstring } from 'mazey';
|
|
252
|
-
|
|
253
|
-
calLongestCommonSubstring('fish', 'finish'); // 3
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
计算两个字符串的最长公共子序列
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
import { calLongestCommonSubsequence } from 'mazey';
|
|
260
|
-
|
|
261
|
-
calLongestCommonSubsequence('fish', 'finish'); // 4
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
命中概率(1% ~ 100%)
|
|
265
|
-
|
|
266
|
-
```
|
|
267
|
-
import { inRate } from 'mazey';
|
|
268
|
-
|
|
269
|
-
inRate(0.5); // 0.01 ~ 1 true / false
|
|
270
|
-
|
|
271
|
-
// 测试准确性
|
|
272
|
-
let trueCount = 0;
|
|
273
|
-
let falseCount = 0;
|
|
274
|
-
new Array(1000000).fill(0).forEach(() => {
|
|
275
|
-
if (inRate(0.5)) {
|
|
276
|
-
trueCount++;
|
|
277
|
-
} else {
|
|
278
|
-
falseCount++;
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
console.log(trueCount, falseCount); // 499994 500006
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### 浏览器信息
|
|
285
|
-
|
|
286
|
-
```
|
|
287
|
-
import { getBrowserType } from 'mazey';
|
|
288
|
-
|
|
289
|
-
getBrowserType(); // {"engine":"webkit","engineVs":"537.36","platform":"desktop","supporter":"chrome","supporterVs":"85.0.4183.121","system":"windows","systemVs":"10"}
|
|
290
|
-
// 外壳和外壳版本 { shell: 'wechat', shellVs: '20' } shell: wechat qq uc 360 2345 sougou liebao maxthon
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### 安全边际
|
|
294
|
-
|
|
295
|
-
判断是否是安全的 PWA 运行环境
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
import { isSafePWAEnv } from 'mazey';
|
|
299
|
-
|
|
300
|
-
isSafePWAEnv(); // true
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### 函数
|
|
304
|
-
|
|
305
|
-
防抖
|
|
306
|
-
|
|
307
|
-
```
|
|
308
|
-
import { debounce } from 'mazey';
|
|
309
|
-
|
|
310
|
-
const foo = debounce(() => {
|
|
311
|
-
console.log('执行 1 秒内再次执行无反应');
|
|
312
|
-
}, 1000, { leading: true })
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
判断是否是有效数字
|
|
316
|
-
|
|
317
|
-
```
|
|
318
|
-
import { isNumber } from 'mazey';
|
|
319
|
-
|
|
320
|
-
isNumber(123); // true
|
|
321
|
-
isNumber('123'); // false
|
|
322
|
-
// 默认情况下 NaN、Infinity 不算有效数字
|
|
323
|
-
isNumber(Infinity); // false
|
|
324
|
-
isNumber(Infinity, { isUnFiniteAsNumber: true }); true
|
|
325
|
-
isNumber(NaN); // false
|
|
326
|
-
isNumber(NaN, { isNaNAsNumber: true, isUnFiniteAsNumber: true }); // true
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
### 调试
|
|
330
|
-
|
|
331
|
-
自定义控制台打印(`console`)
|
|
332
|
-
|
|
333
|
-
```
|
|
334
|
-
import { genCustomConsole } from 'mazey';
|
|
335
|
-
|
|
336
|
-
const myConsole = genCustomConsole({ prefix: 'MazeyLog:' });
|
|
337
|
-
myConsole.log('I am string.'); // MazeyLog: I am string.
|
|
338
|
-
myConsole.info('I am boolean.', true); // MazeyLog: I am boolean. true
|
|
339
|
-
myConsole.info('I am number.', 123, 456); // MazeyLog: I am number. 123 456
|
|
340
|
-
myConsole.info('I am object.', { a: 123, b: 456}); // MazeyLog: I am object. {a: 123, b: 456}
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
[更多接口>>](https://mazey.cn/t/m)
|
|
344
|
-
|
|
345
|
-
## 开发
|
|
346
|
-
|
|
347
|
-
```
|
|
348
|
-
# dev
|
|
349
|
-
npm run dev
|
|
350
|
-
|
|
351
|
-
# build
|
|
352
|
-
npm run build
|
|
353
|
-
|
|
354
|
-
# documentation
|
|
355
|
-
npm run docs
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
## 参考
|
|
359
|
-
|
|
360
|
-
1. [@babel/preset-env conflicts with @babel/plugin-transform-runtime when using core-js@3](https://github.com/babel/babel/issues/10271#issuecomment-528379505)
|
|
361
|
-
2. [@babel/plugin-transform-runtime](https://babeljs.io/docs/en/babel-plugin-transform-runtime)
|
package/examples/index.html
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Test Page</title>
|
|
6
|
-
<link rel="shortcut icon" type="image/png" href="https://mazey.cn/fav/logo-dark-circle-transparent-144x144.png">
|
|
7
|
-
<style>
|
|
8
|
-
.box {
|
|
9
|
-
color: #333;
|
|
10
|
-
}
|
|
11
|
-
</style>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<div class="container">
|
|
15
|
-
<div class="box">
|
|
16
|
-
<span>Box</span>
|
|
17
|
-
</div>
|
|
18
|
-
<div class="s"></div>
|
|
19
|
-
</div>
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
package/examples/index.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isNumber,
|
|
3
|
-
getUrlParam,
|
|
4
|
-
updateQueryParam,
|
|
5
|
-
getHashQueryParam,
|
|
6
|
-
getDomain,
|
|
7
|
-
camelCaseToKebabCase,
|
|
8
|
-
camelCase2Underscore,
|
|
9
|
-
generateRndNum,
|
|
10
|
-
isNonEmptyArray,
|
|
11
|
-
getFileSize,
|
|
12
|
-
isSupportWebp,
|
|
13
|
-
genHashCode,
|
|
14
|
-
debounce,
|
|
15
|
-
genCustomConsole,
|
|
16
|
-
formatDate,
|
|
17
|
-
isValidData
|
|
18
|
-
} from '../src/index';
|
|
19
|
-
|
|
20
|
-
// Sync
|
|
21
|
-
console.log(
|
|
22
|
-
'Is Infinity number?',
|
|
23
|
-
isNumber(Infinity, { isUnFiniteAsNumber: true })
|
|
24
|
-
);
|
|
25
|
-
console.log(
|
|
26
|
-
'Is NaN number?',
|
|
27
|
-
isNumber(NaN, { isNaNAsNumber: true, isUnFiniteAsNumber: true })
|
|
28
|
-
);
|
|
29
|
-
console.log('Did ttt exist?', getHashQueryParam('ttt'));
|
|
30
|
-
console.log(
|
|
31
|
-
'What is t3?',
|
|
32
|
-
getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3')
|
|
33
|
-
);
|
|
34
|
-
console.log(
|
|
35
|
-
'Can query param update successfully?',
|
|
36
|
-
updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3', 'three')
|
|
37
|
-
);
|
|
38
|
-
console.log(
|
|
39
|
-
'What is domain?',
|
|
40
|
-
getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4')
|
|
41
|
-
);
|
|
42
|
-
console.log('Get KebabCase:', camelCaseToKebabCase('aBC'));
|
|
43
|
-
console.log('Get Underscore:', camelCase2Underscore('bBC'));
|
|
44
|
-
console.log('Get a string with random number:', generateRndNum(7));
|
|
45
|
-
console.log('Is non-empty array?', isNonEmptyArray(['a', 123]));
|
|
46
|
-
console.log('Get file size:', getFileSize(2000));
|
|
47
|
-
console.log('Generate a Hash from a string:', genHashCode('123'));
|
|
48
|
-
const genLog = genCustomConsole('GenLog:', {
|
|
49
|
-
isClosed: false,
|
|
50
|
-
showWrap: false,
|
|
51
|
-
showDate: true,
|
|
52
|
-
locales: 'zh-CN'
|
|
53
|
-
});
|
|
54
|
-
genLog.log('test?');
|
|
55
|
-
// const s011101 = ;
|
|
56
|
-
console.log('Default formatDate value:', formatDate());
|
|
57
|
-
// 2022-01-11
|
|
58
|
-
console.log(
|
|
59
|
-
'String formatDate value:',
|
|
60
|
-
formatDate(
|
|
61
|
-
'Tue Jan 11 2022 14:12:26 GMT+0800 (China Standard Time)',
|
|
62
|
-
'yyyy-MM-dd hh:mm:ss'
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
// 2022-01-11 14:12:26
|
|
66
|
-
console.log(
|
|
67
|
-
'Number formatDate value:',
|
|
68
|
-
formatDate(1641881235000, 'yyyy-MM-dd hh:mm:ss')
|
|
69
|
-
);
|
|
70
|
-
// 2022-01-11 14:07:15
|
|
71
|
-
// (new Date(2014, 1, 11), 'MM/dd/yyyy')
|
|
72
|
-
console.log(
|
|
73
|
-
'Date formatDate value:',
|
|
74
|
-
formatDate(new Date(2014, 1, 11), 'MM/dd/yyyy')
|
|
75
|
-
);
|
|
76
|
-
// Date formatDate value: 02/11/2014
|
|
77
|
-
const validData = {
|
|
78
|
-
a: {
|
|
79
|
-
b: {
|
|
80
|
-
c: 413
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const isValidDataResA = isValidData(validData, ['a', 'b', 'c'], 2333);
|
|
86
|
-
const isValidDataResB = isValidData(validData, ['a', 'b', 'c'], 413);
|
|
87
|
-
const isValidDataResC = isValidData(validData, ['d', 'd'], 413);
|
|
88
|
-
|
|
89
|
-
console.log('isValidDataResA:', isValidDataResA);
|
|
90
|
-
console.log('isValidDataResB:', isValidDataResB);
|
|
91
|
-
console.log('isValidDataResC:', isValidDataResC);
|
|
92
|
-
|
|
93
|
-
// isValidDataResA: false
|
|
94
|
-
// isValidDataResB: true
|
|
95
|
-
// isValidDataResC: false
|
|
96
|
-
|
|
97
|
-
// Async
|
|
98
|
-
(async () => {
|
|
99
|
-
console.log('Detect webp support:', await isSupportWebp());
|
|
100
|
-
|
|
101
|
-
// debounce
|
|
102
|
-
console.log('Test debounce - begin');
|
|
103
|
-
const c = debounce(
|
|
104
|
-
() => {
|
|
105
|
-
console.log('Test debounce - fun myself');
|
|
106
|
-
},
|
|
107
|
-
3000,
|
|
108
|
-
true
|
|
109
|
-
);
|
|
110
|
-
console.log('Test debounce - invoke first');
|
|
111
|
-
c();
|
|
112
|
-
setTimeout(() => {
|
|
113
|
-
c();
|
|
114
|
-
console.log('Test debounce - 2000ms second');
|
|
115
|
-
}, 2000);
|
|
116
|
-
setTimeout(() => {
|
|
117
|
-
c();
|
|
118
|
-
console.log('Test debounce - 10000ms third');
|
|
119
|
-
}, 10000);
|
|
120
|
-
console.log('Test debounce - end');
|
|
121
|
-
})();
|
package/images/mazey-v1.4.39.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="88" height="20" role="img" aria-label="npm: v1.4.39"><title>npm: v1.4.39</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="88" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="35" height="20" fill="#555"/><rect x="35" width="53" height="20" fill="#007ec6"/><rect width="88" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="185" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">npm</text><text x="185" y="140" transform="scale(.1)" fill="#fff" textLength="250">npm</text><text aria-hidden="true" x="605" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">v1.4.39</text><text x="605" y="140" transform="scale(.1)" fill="#fff" textLength="430">v1.4.39</text></g></svg>
|