qmwts 1.2.1 → 1.2.2
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.
|
@@ -46,8 +46,8 @@ exports.default = {
|
|
|
46
46
|
getAncestors(array = [], id, idKey = 'id', parentKey = 'parentId') {
|
|
47
47
|
// 建立 id - item 的映射
|
|
48
48
|
const idMap = new Map();
|
|
49
|
-
for (
|
|
50
|
-
const
|
|
49
|
+
for (const e of array) {
|
|
50
|
+
const { [idKey]: itemId } = e;
|
|
51
51
|
idMap.set(itemId, e);
|
|
52
52
|
}
|
|
53
53
|
const result = [];
|
|
@@ -75,8 +75,8 @@ exports.default = {
|
|
|
75
75
|
getDescendants(array = [], id, idKey = 'id', parentKey = 'parentId') {
|
|
76
76
|
const result = [];
|
|
77
77
|
const dfs = (currentId) => {
|
|
78
|
-
for (
|
|
79
|
-
const
|
|
78
|
+
for (const e of array) {
|
|
79
|
+
const { [idKey]: itemId, [parentKey]: pid } = e;
|
|
80
80
|
if (pid === currentId) {
|
|
81
81
|
result.unshift(e);
|
|
82
82
|
dfs(itemId);
|