@d-matrix/utils 1.15.0 → 1.16.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/dist/echarts.d.ts +3 -0
- package/dist/echarts.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/package.json +10 -2
- package/readme.md +27 -0
package/dist/echarts.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import deepmerge from 'deepmerge';
|
|
2
|
+
const combineMerge = (target, source, options) => {
|
|
3
|
+
const destination = target.slice();
|
|
4
|
+
source.forEach((item, index) => {
|
|
5
|
+
if (typeof destination[index] === 'undefined') {
|
|
6
|
+
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
|
|
7
|
+
}
|
|
8
|
+
else if (options.isMergeableObject(item)) {
|
|
9
|
+
destination[index] = deepmerge(target[index], item, options);
|
|
10
|
+
}
|
|
11
|
+
else if (target.indexOf(item) === -1) {
|
|
12
|
+
destination.push(item);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return destination;
|
|
16
|
+
};
|
|
17
|
+
export function mergeOption(defaults, overrides, option) {
|
|
18
|
+
return deepmerge(defaults, overrides, Object.assign({ arrayMerge: combineMerge }, option));
|
|
19
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/react/index.d.ts
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-matrix/utils",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.1",
|
|
5
5
|
"description": "A dozen of utils for Front-End Development",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
+
"build:public": "tsc --project ./tsconfig.e2e.json",
|
|
9
10
|
"prebuild": "npm run clean",
|
|
10
11
|
"postpublish": "echo \"wait for 3 seconds, then sync cnpm\" && npm run wait3s && npm run cnpm:sync",
|
|
11
12
|
"prepublishOnly": "npm run build",
|
|
@@ -16,7 +17,8 @@
|
|
|
16
17
|
"test:tsd": "tsd",
|
|
17
18
|
"postversion": "git push && git push --tags",
|
|
18
19
|
"wait3s": "node -e \"setTimeout(() => process.exit(0), 3000)\"",
|
|
19
|
-
"cnpm:sync": "cnpm sync %npm_package_name%"
|
|
20
|
+
"cnpm:sync": "cnpm sync %npm_package_name%",
|
|
21
|
+
"start": "serve -l 64055 -n ./public"
|
|
20
22
|
},
|
|
21
23
|
"engines": {
|
|
22
24
|
"node": ">=16.20.0"
|
|
@@ -41,20 +43,26 @@
|
|
|
41
43
|
"peerDependencies": {
|
|
42
44
|
"@types/react": "^16.8.0",
|
|
43
45
|
"@types/react-dom": "^16.9.0",
|
|
46
|
+
"echarts": "^3.0.0 || ^4.0.0 || ^5.0.0",
|
|
44
47
|
"react": "^16.8.0 || ^17.0.0",
|
|
45
48
|
"react-dom": "^16.9.0",
|
|
46
49
|
"typescript": "~4.3.2"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
52
|
+
"@types/chai-subset": "^1.3.5",
|
|
49
53
|
"@vitejs/plugin-react": "^4.2.1",
|
|
54
|
+
"chai-subset": "^1.6.0",
|
|
50
55
|
"cnpm": "^9.4.0",
|
|
51
56
|
"cypress": "^13.6.6",
|
|
52
57
|
"expect-type": "^0.19.0",
|
|
58
|
+
"read-excel-file": "^5.8.4",
|
|
53
59
|
"rimraf": "^5.0.5",
|
|
60
|
+
"serve": "^14.2.3",
|
|
54
61
|
"vite": "^4.5.2"
|
|
55
62
|
},
|
|
56
63
|
"dependencies": {
|
|
57
64
|
"decimal.js-light": "^2.5.1",
|
|
65
|
+
"deepmerge": "^4.3.1",
|
|
58
66
|
"react-fast-compare": "^3.2.2"
|
|
59
67
|
}
|
|
60
68
|
}
|
package/readme.md
CHANGED
|
@@ -19,6 +19,7 @@ A dozen of utils for Front-End Development
|
|
|
19
19
|
- [operator](#operator)
|
|
20
20
|
- [decimal](#decimal)
|
|
21
21
|
- [object](#object)
|
|
22
|
+
- [echarts](#echarts)
|
|
22
23
|
|
|
23
24
|
### clipboard
|
|
24
25
|
|
|
@@ -433,6 +434,12 @@ removeZeroValueKeys({ a: '', b: 'abc', c: undefined, d: null, e: NaN, f: -1, g:
|
|
|
433
434
|
// { b: 'abc', f: -1 }
|
|
434
435
|
```
|
|
435
436
|
|
|
437
|
+
## echarts
|
|
438
|
+
|
|
439
|
+
- `mergeOption(defaults: EChartsOption, overrides: EChartsOption, option?: deepmerge.Options): EChartsOption`
|
|
440
|
+
|
|
441
|
+
deep merge Echarts配置,用法见[测试用例](./tests//echarts/echarts.cy.ts)
|
|
442
|
+
|
|
436
443
|
## 测试
|
|
437
444
|
|
|
438
445
|
运行全部组件测试
|
|
@@ -447,6 +454,26 @@ npm run cy:run -- --component
|
|
|
447
454
|
npm run cy:run -- --component --spec tests/date.cy.ts
|
|
448
455
|
```
|
|
449
456
|
|
|
457
|
+
运行E2E测试
|
|
458
|
+
|
|
459
|
+
将`src`通过`tsc` build到`public/dist`目录
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
npm run build:public
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
启动一个Web服务器来访问`public/index.html`文件,`dist`目录的脚本可以通过`<script type="module"/>`引入
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
npm run serve
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
最后启动cypress GUI客户端,选择E2E测试
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
npm run cy:open
|
|
475
|
+
```
|
|
476
|
+
|
|
450
477
|
## 发布
|
|
451
478
|
|
|
452
479
|
更新package version:
|