@zhongguo168a/yxeditor-common 0.0.174 → 0.0.176
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/index.d.ts +4 -4
- package/dist/index.esm.js +14 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -462,7 +462,7 @@ declare class TreeNode<T = any> {
|
|
|
462
462
|
* @param mode
|
|
463
463
|
* @returns
|
|
464
464
|
*/
|
|
465
|
-
toArray(mode
|
|
465
|
+
toArray(mode?: "BFS" | "DFS"): TreeNode[];
|
|
466
466
|
/**
|
|
467
467
|
* 广度优先遍历(BFS):从当前节点开始,逐层遍历子树
|
|
468
468
|
* @param f - 节点处理函数,返回 false 表示停止遍历
|
|
@@ -592,7 +592,7 @@ declare class TreeRoot<NODE = any> extends EventDispatcher {
|
|
|
592
592
|
clone(): TreeRoot;
|
|
593
593
|
toString(): string;
|
|
594
594
|
createNode(id: string, isLeaf?: boolean): TreeNode;
|
|
595
|
-
flat(mode
|
|
595
|
+
flat(mode?: "BFS" | "DFS"): {
|
|
596
596
|
[key: string]: any;
|
|
597
597
|
};
|
|
598
598
|
unflag(object: {
|
|
@@ -651,10 +651,10 @@ declare class List<T = any> {
|
|
|
651
651
|
clear(useIter?: boolean): void;
|
|
652
652
|
/**
|
|
653
653
|
* 克隆自身所有项到【target】对象,并返回【target】对象
|
|
654
|
-
* @param target
|
|
654
|
+
* @param target 如果为空,则创建一个List
|
|
655
655
|
* @param useIter 使用遍历的方式可以触发onSet
|
|
656
656
|
*/
|
|
657
|
-
clone(target
|
|
657
|
+
clone(target?: List, useIter?: boolean): this;
|
|
658
658
|
get length(): number;
|
|
659
659
|
insertAt(index: number, ...item: T[]): void;
|
|
660
660
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -1533,7 +1533,7 @@ class MapUtil {
|
|
|
1533
1533
|
for (let key in obj) {
|
|
1534
1534
|
let val = obj[key];
|
|
1535
1535
|
let type = typeof val;
|
|
1536
|
-
let id = path + split + key;
|
|
1536
|
+
let id = path ? path + split + key : key;
|
|
1537
1537
|
switch (type) {
|
|
1538
1538
|
case "object":
|
|
1539
1539
|
this._flat(val, result, id, split);
|
|
@@ -1546,7 +1546,13 @@ class MapUtil {
|
|
|
1546
1546
|
unflat(object, split = "/") {
|
|
1547
1547
|
let result = {};
|
|
1548
1548
|
for (let key in object) {
|
|
1549
|
-
let path
|
|
1549
|
+
let path;
|
|
1550
|
+
if (split != "/") {
|
|
1551
|
+
key.replace(split, "/");
|
|
1552
|
+
}
|
|
1553
|
+
else {
|
|
1554
|
+
path = key;
|
|
1555
|
+
}
|
|
1550
1556
|
this.setByPath(result, "/" + path, object[key]);
|
|
1551
1557
|
}
|
|
1552
1558
|
return result;
|
|
@@ -2071,7 +2077,7 @@ class TreeNode {
|
|
|
2071
2077
|
* @param mode
|
|
2072
2078
|
* @returns
|
|
2073
2079
|
*/
|
|
2074
|
-
toArray(mode) {
|
|
2080
|
+
toArray(mode = "BFS") {
|
|
2075
2081
|
let result = [];
|
|
2076
2082
|
switch (mode) {
|
|
2077
2083
|
case "BFS":
|
|
@@ -2585,7 +2591,7 @@ class TreeRoot extends EventDispatcher {
|
|
|
2585
2591
|
node.setRoot(this);
|
|
2586
2592
|
return node;
|
|
2587
2593
|
}
|
|
2588
|
-
flat(mode) {
|
|
2594
|
+
flat(mode = "BFS") {
|
|
2589
2595
|
let result = {};
|
|
2590
2596
|
switch (mode) {
|
|
2591
2597
|
case "BFS":
|
|
@@ -2815,10 +2821,13 @@ class List {
|
|
|
2815
2821
|
}
|
|
2816
2822
|
/**
|
|
2817
2823
|
* 克隆自身所有项到【target】对象,并返回【target】对象
|
|
2818
|
-
* @param target
|
|
2824
|
+
* @param target 如果为空,则创建一个List
|
|
2819
2825
|
* @param useIter 使用遍历的方式可以触发onSet
|
|
2820
2826
|
*/
|
|
2821
2827
|
clone(target, useIter = true) {
|
|
2828
|
+
if (!target) {
|
|
2829
|
+
target = new List();
|
|
2830
|
+
}
|
|
2822
2831
|
let data = this._array;
|
|
2823
2832
|
if (useIter) {
|
|
2824
2833
|
for (let i = 0; i < data.length; i++) {
|