@vope/utils 1.7.2 → 1.7.4
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/README.md +1 -1
- package/dist/flat-tree.d.ts +5 -0
- package/dist/flat-tree.js +16 -0
- package/dist/index.cjs.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/flat-tree.d.ts
CHANGED
|
@@ -77,6 +77,10 @@ export declare class FlatTree<K extends string, T extends {
|
|
|
77
77
|
* 获取上级节点
|
|
78
78
|
*/
|
|
79
79
|
getSup(value: Value): T | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* 获取子级节点
|
|
82
|
+
*/
|
|
83
|
+
getSub(value: Value, callback?: (data: T) => void): T[] | undefined;
|
|
80
84
|
/**
|
|
81
85
|
* 是否含有节点
|
|
82
86
|
*/
|
|
@@ -88,6 +92,7 @@ export declare class FlatTree<K extends string, T extends {
|
|
|
88
92
|
forEach(callback: (data: T) => void, mode?: FlatTree.Mode): void;
|
|
89
93
|
/**
|
|
90
94
|
* 查询节点
|
|
95
|
+
* @param callback 节点回调,返回false则停止查询
|
|
91
96
|
* @param mode 遍历模式
|
|
92
97
|
*/
|
|
93
98
|
some(callback: (data: T) => boolean, mode?: FlatTree.Mode): boolean;
|
package/dist/flat-tree.js
CHANGED
|
@@ -132,6 +132,21 @@ class FlatTree {
|
|
|
132
132
|
const pid = this.ups.get(value);
|
|
133
133
|
return isNull(pid) ? void 0 : this.memory.get(pid);
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* 获取子级节点
|
|
137
|
+
*/
|
|
138
|
+
getSub(value, callback) {
|
|
139
|
+
const { memory } = this;
|
|
140
|
+
const tmp = this.downs.get(value);
|
|
141
|
+
if (!tmp) return;
|
|
142
|
+
const list = [];
|
|
143
|
+
for (const id of tmp) {
|
|
144
|
+
const data = memory.get(id);
|
|
145
|
+
callback?.(data);
|
|
146
|
+
list.push(data);
|
|
147
|
+
}
|
|
148
|
+
return list;
|
|
149
|
+
}
|
|
135
150
|
/**
|
|
136
151
|
* 是否含有节点
|
|
137
152
|
*/
|
|
@@ -155,6 +170,7 @@ class FlatTree {
|
|
|
155
170
|
}
|
|
156
171
|
/**
|
|
157
172
|
* 查询节点
|
|
173
|
+
* @param callback 节点回调,返回false则停止查询
|
|
158
174
|
* @param mode 遍历模式
|
|
159
175
|
*/
|
|
160
176
|
some(callback, mode) {
|
package/dist/index.cjs.js
CHANGED
|
@@ -1387,6 +1387,21 @@ var FlatTree = class {
|
|
|
1387
1387
|
const pid = this.ups.get(value);
|
|
1388
1388
|
return isNull(pid) ? void 0 : this.memory.get(pid);
|
|
1389
1389
|
}
|
|
1390
|
+
/**
|
|
1391
|
+
* 获取子级节点
|
|
1392
|
+
*/
|
|
1393
|
+
getSub(value, callback) {
|
|
1394
|
+
const { memory } = this;
|
|
1395
|
+
const tmp = this.downs.get(value);
|
|
1396
|
+
if (!tmp) return;
|
|
1397
|
+
const list = [];
|
|
1398
|
+
for (const id of tmp) {
|
|
1399
|
+
const data = memory.get(id);
|
|
1400
|
+
callback?.(data);
|
|
1401
|
+
list.push(data);
|
|
1402
|
+
}
|
|
1403
|
+
return list;
|
|
1404
|
+
}
|
|
1390
1405
|
/**
|
|
1391
1406
|
* 是否含有节点
|
|
1392
1407
|
*/
|
|
@@ -1410,6 +1425,7 @@ var FlatTree = class {
|
|
|
1410
1425
|
}
|
|
1411
1426
|
/**
|
|
1412
1427
|
* 查询节点
|
|
1428
|
+
* @param callback 节点回调,返回false则停止查询
|
|
1413
1429
|
* @param mode 遍历模式
|
|
1414
1430
|
*/
|
|
1415
1431
|
some(callback, mode) {
|