mazey 3.1.0 → 3.2.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/LICENSE +21 -21
- package/README.md +496 -496
- package/README_CN.md +334 -334
- package/index.js +3 -3
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +102 -63
- 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 +109 -108
- package/scripts/release.js +28 -28
- package/src/example.html +21 -21
- package/src/example.ts +49 -49
- package/src/index.ts +1426 -1384
package/package.json
CHANGED
|
@@ -1,108 +1,109 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mazey",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Mazey's library for front end.",
|
|
5
|
-
"main": "lib/index.cjs.js",
|
|
6
|
-
"module": "lib/index.esm.js",
|
|
7
|
-
"typings": "lib/index.d.ts",
|
|
8
|
-
"mainEntryPointFilePath": "lib/index.d.ts",
|
|
9
|
-
"directories": {
|
|
10
|
-
"lib": "./lib"
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"dev": "webpack-dev-server --open",
|
|
14
|
-
"build": "npx rollup -c",
|
|
15
|
-
"test": "jest",
|
|
16
|
-
"docs": "npx typedoc --out docs/ src/",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
"@babel/
|
|
63
|
-
"@babel/plugin-proposal-
|
|
64
|
-
"@babel/plugin-
|
|
65
|
-
"@babel/
|
|
66
|
-
"@babel/preset-
|
|
67
|
-
"@
|
|
68
|
-
"@commitlint/
|
|
69
|
-
"@
|
|
70
|
-
"@typescript-eslint/
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"eslint
|
|
74
|
-
"eslint-
|
|
75
|
-
"eslint-plugin-
|
|
76
|
-
"eslint-plugin-
|
|
77
|
-
"eslint-plugin-
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"prettier
|
|
85
|
-
"
|
|
86
|
-
"rollup
|
|
87
|
-
"rollup-plugin-
|
|
88
|
-
"rollup-plugin-
|
|
89
|
-
"rollup-plugin-
|
|
90
|
-
"rollup-plugin-
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"webpack
|
|
96
|
-
"webpack-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mazey",
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"description": "Mazey's library for front end.",
|
|
5
|
+
"main": "lib/index.cjs.js",
|
|
6
|
+
"module": "lib/index.esm.js",
|
|
7
|
+
"typings": "lib/index.d.ts",
|
|
8
|
+
"mainEntryPointFilePath": "lib/index.d.ts",
|
|
9
|
+
"directories": {
|
|
10
|
+
"lib": "./lib"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "webpack-dev-server --open",
|
|
14
|
+
"build": "npx rollup -c",
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"[Give Up]docs": "npx typedoc --out docs/ src/",
|
|
17
|
+
"docs": "npx typedoc",
|
|
18
|
+
"lint-and-fix": "eslint ./src/index.ts --ext 'ts,tsx' --fix",
|
|
19
|
+
"preview": "npm run build && npm run test && npm run docs",
|
|
20
|
+
"release": "npm run preview && npm publish && node ./scripts/release.js"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/mazeyqian/mazey.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"javascript",
|
|
28
|
+
"function",
|
|
29
|
+
"math",
|
|
30
|
+
"load",
|
|
31
|
+
"css",
|
|
32
|
+
"debounce",
|
|
33
|
+
"throttle",
|
|
34
|
+
"trim",
|
|
35
|
+
"clone",
|
|
36
|
+
"json",
|
|
37
|
+
"random",
|
|
38
|
+
"dom",
|
|
39
|
+
"style",
|
|
40
|
+
"url",
|
|
41
|
+
"hash",
|
|
42
|
+
"storage",
|
|
43
|
+
"cookie",
|
|
44
|
+
"calculate",
|
|
45
|
+
"formula",
|
|
46
|
+
"browser",
|
|
47
|
+
"performance",
|
|
48
|
+
"pwa",
|
|
49
|
+
"console"
|
|
50
|
+
],
|
|
51
|
+
"author": {
|
|
52
|
+
"name": "Mazey Chu",
|
|
53
|
+
"email": "mazeyqian@gmail.com",
|
|
54
|
+
"url": "https://blog.mazey.net"
|
|
55
|
+
},
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/mazeyqian/mazey/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/mazeyqian/mazey#readme",
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@babel/core": "7.8.4",
|
|
63
|
+
"@babel/plugin-proposal-class-properties": "7.10.4",
|
|
64
|
+
"@babel/plugin-proposal-object-rest-spread": "7.11.0",
|
|
65
|
+
"@babel/plugin-transform-runtime": "7.11.0",
|
|
66
|
+
"@babel/preset-env": "7.5.5",
|
|
67
|
+
"@babel/preset-typescript": "7.10.4",
|
|
68
|
+
"@commitlint/cli": "^8.3.5",
|
|
69
|
+
"@commitlint/config-conventional": "^8.3.4",
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
71
|
+
"@typescript-eslint/parser": "^4.22.0",
|
|
72
|
+
"clean-webpack-plugin": "1.0.1",
|
|
73
|
+
"eslint": "6.8.0",
|
|
74
|
+
"eslint-config-standard": "14.1.0",
|
|
75
|
+
"eslint-plugin-import": "2.20.1",
|
|
76
|
+
"eslint-plugin-node": "11.0.0",
|
|
77
|
+
"eslint-plugin-promise": "4.2.1",
|
|
78
|
+
"eslint-plugin-standard": "4.0.1",
|
|
79
|
+
"execa": "^4.1.0",
|
|
80
|
+
"html-webpack-plugin": "3.2.0",
|
|
81
|
+
"husky": "4.3.8",
|
|
82
|
+
"jest": "^27.5.1",
|
|
83
|
+
"lint-staged": "10.0.8",
|
|
84
|
+
"prettier": "1.19.1",
|
|
85
|
+
"prettier-eslint-cli": "5.0.0",
|
|
86
|
+
"rollup": "^1.31.1",
|
|
87
|
+
"rollup-plugin-babel": "^4.3.3",
|
|
88
|
+
"rollup-plugin-cleaner": "^1.0.0",
|
|
89
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
90
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
91
|
+
"rollup-plugin-typescript2": "^0.27.2",
|
|
92
|
+
"ts-loader": "8.0.2",
|
|
93
|
+
"typedoc": "0.18.0",
|
|
94
|
+
"typescript": "3.9.7",
|
|
95
|
+
"webpack": "4.30.0",
|
|
96
|
+
"webpack-cli": "3.3.2",
|
|
97
|
+
"webpack-dev-server": "3.10.3"
|
|
98
|
+
},
|
|
99
|
+
"husky": {
|
|
100
|
+
"hooks": {
|
|
101
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
102
|
+
"pre-commit": "lint-staged"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"dependencies": {
|
|
106
|
+
"@babel/runtime-corejs3": "^7.11.2",
|
|
107
|
+
"core-js": "^3.6.5"
|
|
108
|
+
}
|
|
109
|
+
}
|
package/scripts/release.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
|
-
// release
|
|
4
|
-
const execa = require('execa');
|
|
5
|
-
const pkgVersion = process.env.VERSION || require('../package.json').version;
|
|
6
|
-
|
|
7
|
-
// Main
|
|
8
|
-
(async () => {
|
|
9
|
-
const releaseVersion = `v${pkgVersion}`;
|
|
10
|
-
const { stdout: releaseStdout } = await execa('echo', [`Start release ${releaseVersion}...`]);
|
|
11
|
-
console.log(releaseStdout);
|
|
12
|
-
// Commit Stdout
|
|
13
|
-
const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
|
|
14
|
-
if (diffStdout) {
|
|
15
|
-
console.log('Committing changes...');
|
|
16
|
-
await execa('git', ['add', '-A']);
|
|
17
|
-
await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
|
|
18
|
-
} else {
|
|
19
|
-
console.log('No changes to commit.');
|
|
20
|
-
}
|
|
21
|
-
// Push
|
|
22
|
-
console.log('Pushing to GitHub...');
|
|
23
|
-
await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
|
|
24
|
-
await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
|
|
25
|
-
await execa('git', ['push']);
|
|
26
|
-
|
|
27
|
-
console.log('All done.');
|
|
28
|
-
})();
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
// release
|
|
4
|
+
const execa = require('execa');
|
|
5
|
+
const pkgVersion = process.env.VERSION || require('../package.json').version;
|
|
6
|
+
|
|
7
|
+
// Main
|
|
8
|
+
(async () => {
|
|
9
|
+
const releaseVersion = `v${pkgVersion}`;
|
|
10
|
+
const { stdout: releaseStdout } = await execa('echo', [`Start release ${releaseVersion}...`]);
|
|
11
|
+
console.log(releaseStdout);
|
|
12
|
+
// Commit Stdout
|
|
13
|
+
const { stdout: diffStdout } = await execa('git', ['diff'], { stdio: 'pipe' });
|
|
14
|
+
if (diffStdout) {
|
|
15
|
+
console.log('Committing changes...');
|
|
16
|
+
await execa('git', ['add', '-A']);
|
|
17
|
+
await execa('git', ['commit', '-m', `release: ${releaseVersion}`]);
|
|
18
|
+
} else {
|
|
19
|
+
console.log('No changes to commit.');
|
|
20
|
+
}
|
|
21
|
+
// Push
|
|
22
|
+
console.log('Pushing to GitHub...');
|
|
23
|
+
await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
|
|
24
|
+
await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
|
|
25
|
+
await execa('git', ['push']);
|
|
26
|
+
|
|
27
|
+
console.log('All done.');
|
|
28
|
+
})();
|
package/src/example.html
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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>
|
|
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/src/example.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isNumber,
|
|
3
|
-
getQueryParam,
|
|
4
|
-
getUrlParam,
|
|
5
|
-
updateQueryParam,
|
|
6
|
-
getHashQueryParam,
|
|
7
|
-
getDomain,
|
|
8
|
-
camelCaseToKebabCase,
|
|
9
|
-
camelCase2Underscore,
|
|
10
|
-
mTrim,
|
|
11
|
-
newLine,
|
|
12
|
-
deepCopyObject,
|
|
13
|
-
isJsonString,
|
|
14
|
-
generateRndNum,
|
|
15
|
-
} from './index';
|
|
16
|
-
|
|
17
|
-
// 数字测试
|
|
18
|
-
console.log('数字测试:', isNumber(Infinity, { isUnFiniteAsNumber: true }));
|
|
19
|
-
|
|
20
|
-
const hashParam = getHashQueryParam('ttt');
|
|
21
|
-
|
|
22
|
-
console.log('hashParam', hashParam);
|
|
23
|
-
|
|
24
|
-
// const t3 = getQueryParam('t3');
|
|
25
|
-
// const t4 = getQueryParam('t4');
|
|
26
|
-
|
|
27
|
-
// console.log('t3', t3);
|
|
28
|
-
// console.log('t4', t4);
|
|
29
|
-
|
|
30
|
-
// const t3 = getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3');
|
|
31
|
-
// const t4 = getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4');
|
|
32
|
-
|
|
33
|
-
// const t3 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3', 'three');
|
|
34
|
-
// const t4 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4', 'four');
|
|
35
|
-
|
|
36
|
-
// const t3 = getHashQueryParam('t3'); // 3
|
|
37
|
-
// const t4 = getHashQueryParam('t4'); // 4
|
|
38
|
-
|
|
39
|
-
// const t3 = getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4'); // example.com
|
|
40
|
-
// const t4 = getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']); // example.com/test/thanks
|
|
41
|
-
|
|
42
|
-
// const m1 = camelCaseToKebabCase('aBC'); // a-b-c
|
|
43
|
-
// const m2 = camelCase2Underscore('bBC'); // a_b_c
|
|
44
|
-
|
|
45
|
-
const m1 = generateRndNum(4); // '9730'
|
|
46
|
-
const m2 = generateRndNum(7); // '2262490'
|
|
47
|
-
|
|
48
|
-
console.log('m1', m1);
|
|
49
|
-
console.log('m2', m2);
|
|
1
|
+
import {
|
|
2
|
+
isNumber,
|
|
3
|
+
getQueryParam,
|
|
4
|
+
getUrlParam,
|
|
5
|
+
updateQueryParam,
|
|
6
|
+
getHashQueryParam,
|
|
7
|
+
getDomain,
|
|
8
|
+
camelCaseToKebabCase,
|
|
9
|
+
camelCase2Underscore,
|
|
10
|
+
mTrim,
|
|
11
|
+
newLine,
|
|
12
|
+
deepCopyObject,
|
|
13
|
+
isJsonString,
|
|
14
|
+
generateRndNum,
|
|
15
|
+
} from './index';
|
|
16
|
+
|
|
17
|
+
// 数字测试
|
|
18
|
+
console.log('数字测试:', isNumber(Infinity, { isUnFiniteAsNumber: true }));
|
|
19
|
+
|
|
20
|
+
const hashParam = getHashQueryParam('ttt');
|
|
21
|
+
|
|
22
|
+
console.log('hashParam', hashParam);
|
|
23
|
+
|
|
24
|
+
// const t3 = getQueryParam('t3');
|
|
25
|
+
// const t4 = getQueryParam('t4');
|
|
26
|
+
|
|
27
|
+
// console.log('t3', t3);
|
|
28
|
+
// console.log('t4', t4);
|
|
29
|
+
|
|
30
|
+
// const t3 = getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3');
|
|
31
|
+
// const t4 = getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4');
|
|
32
|
+
|
|
33
|
+
// const t3 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3', 'three');
|
|
34
|
+
// const t4 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4', 'four');
|
|
35
|
+
|
|
36
|
+
// const t3 = getHashQueryParam('t3'); // 3
|
|
37
|
+
// const t4 = getHashQueryParam('t4'); // 4
|
|
38
|
+
|
|
39
|
+
// const t3 = getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4'); // example.com
|
|
40
|
+
// const t4 = getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']); // example.com/test/thanks
|
|
41
|
+
|
|
42
|
+
// const m1 = camelCaseToKebabCase('aBC'); // a-b-c
|
|
43
|
+
// const m2 = camelCase2Underscore('bBC'); // a_b_c
|
|
44
|
+
|
|
45
|
+
const m1 = generateRndNum(4); // '9730'
|
|
46
|
+
const m2 = generateRndNum(7); // '2262490'
|
|
47
|
+
|
|
48
|
+
console.log('m1', m1);
|
|
49
|
+
console.log('m2', m2);
|