-
Notifications
You must be signed in to change notification settings - Fork 0
/
pro.js
67 lines (55 loc) · 1.19 KB
/
pro.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
63
64
65
66
67
/**
* @description 版本引用的先后顺序;
*/
var tree2 = {
name: "page.js",
require: [
{
name: "[email protected]",
require: [
{
name: "[email protected]",
},
{
name: "[email protected]",
}
]
},
{
name: "[email protected]",
require: [
{
name: "[email protected]",
},
{
name: "[email protected]",
}
]
},
{
name: "[email protected]",
}
]
};
const versionResolve = (tree2) => {
const require = tree2.require;
const outerMap = [];
const innerMap = [];
require.map(item => {
outerMap.push(item.name);
item.require?.map(innerItem => {
innerMap.push(innerItem.name);
});
});
// innerMap处理
const _ver = [];
for (let i = 0;i < innerMap.length; i++) {
_ver.push(innerMap[i]?.split('@')[0]);
}
const trimArr = Array.from(new Set([..._ver]));
trimArr.forEach()
const _innerMap = Array.from(new Set([...innerMap])); // 去重处理;
return _innerMap.concat(outerMap);
// return result;
}
console.log('versionResolve', versionResolve(tree2));