@soratani-code/samtools 1.3.5 → 1.3.6
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/lib/tree.d.ts +1 -0
- package/lib/tree.js +16 -1
- package/package.json +1 -1
package/lib/tree.d.ts
CHANGED
package/lib/tree.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateNodeFormKey = exports.findNodeFormKey = void 0;
|
|
3
|
+
exports.toList = exports.updateNodeFormKey = exports.findNodeFormKey = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
function findNodeFormKey(key, nodes, id) {
|
|
6
6
|
if (!id)
|
|
@@ -37,3 +37,18 @@ function updateNodeFormKey(key, nodes, id, value) {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
exports.updateNodeFormKey = updateNodeFormKey;
|
|
40
|
+
function toList(nodes) {
|
|
41
|
+
const tree = (0, lodash_1.cloneDeep)(nodes);
|
|
42
|
+
const result = [];
|
|
43
|
+
const queue = [...tree];
|
|
44
|
+
while (queue.length > 0) {
|
|
45
|
+
const node = queue.shift();
|
|
46
|
+
const children = (0, lodash_1.get)(node, 'children', []);
|
|
47
|
+
result.push((0, lodash_1.omit)(node, 'children'));
|
|
48
|
+
if (children.length) {
|
|
49
|
+
queue.push(...children);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
exports.toList = toList;
|