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/package.json CHANGED
@@ -1,108 +1,109 @@
1
- {
2
- "name": "mazey",
3
- "version": "3.1.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
- "docs": "npx typedoc --out docs/ src/",
17
- "lint-and-fix": "eslint ./src/index.ts --ext 'ts,tsx' --fix",
18
- "preview": "npm run build && npm run test && npm run docs",
19
- "release": "npm run preview && npm publish && node ./scripts/release.js"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/mazeyqian/mazey.git"
24
- },
25
- "keywords": [
26
- "javascript",
27
- "function",
28
- "math",
29
- "load",
30
- "css",
31
- "debounce",
32
- "throttle",
33
- "trim",
34
- "clone",
35
- "json",
36
- "random",
37
- "dom",
38
- "style",
39
- "url",
40
- "hash",
41
- "storage",
42
- "cookie",
43
- "calculate",
44
- "formula",
45
- "browser",
46
- "performance",
47
- "pwa",
48
- "console"
49
- ],
50
- "author": {
51
- "name": "Mazey Chu",
52
- "email": "mazeyqian@gmail.com",
53
- "url": "https://blog.mazey.net"
54
- },
55
- "license": "MIT",
56
- "bugs": {
57
- "url": "https://github.com/mazeyqian/mazey/issues"
58
- },
59
- "homepage": "https://github.com/mazeyqian/mazey#readme",
60
- "devDependencies": {
61
- "@babel/core": "7.8.4",
62
- "@babel/plugin-proposal-class-properties": "7.10.4",
63
- "@babel/plugin-proposal-object-rest-spread": "7.11.0",
64
- "@babel/plugin-transform-runtime": "7.11.0",
65
- "@babel/preset-env": "7.5.5",
66
- "@babel/preset-typescript": "7.10.4",
67
- "@commitlint/cli": "^8.3.5",
68
- "@commitlint/config-conventional": "^8.3.4",
69
- "@typescript-eslint/eslint-plugin": "^4.22.0",
70
- "@typescript-eslint/parser": "^4.22.0",
71
- "clean-webpack-plugin": "1.0.1",
72
- "eslint": "6.8.0",
73
- "eslint-config-standard": "14.1.0",
74
- "eslint-plugin-import": "2.20.1",
75
- "eslint-plugin-node": "11.0.0",
76
- "eslint-plugin-promise": "4.2.1",
77
- "eslint-plugin-standard": "4.0.1",
78
- "execa": "^4.1.0",
79
- "html-webpack-plugin": "3.2.0",
80
- "husky": "4.3.8",
81
- "jest": "^27.5.1",
82
- "lint-staged": "10.0.8",
83
- "prettier": "1.19.1",
84
- "prettier-eslint-cli": "5.0.0",
85
- "rollup": "^1.31.1",
86
- "rollup-plugin-babel": "^4.3.3",
87
- "rollup-plugin-cleaner": "^1.0.0",
88
- "rollup-plugin-commonjs": "^10.1.0",
89
- "rollup-plugin-terser": "^7.0.2",
90
- "rollup-plugin-typescript2": "^0.27.2",
91
- "ts-loader": "8.0.2",
92
- "typedoc": "0.18.0",
93
- "typescript": "3.9.7",
94
- "webpack": "4.30.0",
95
- "webpack-cli": "3.3.2",
96
- "webpack-dev-server": "3.10.3"
97
- },
98
- "husky": {
99
- "hooks": {
100
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
101
- "pre-commit": "lint-staged"
102
- }
103
- },
104
- "dependencies": {
105
- "@babel/runtime-corejs3": "^7.11.2",
106
- "core-js": "^3.6.5"
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
+ }
@@ -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);