Skip to content

Commit

Permalink
描述修改
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuge7 committed Dec 27, 2023
1 parent 7705c95 commit c0baada
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,19 @@ getAncestorsById(trees: Array, config: Object, idValue: any): Array

节点列表

## 获取全部节点祖籍
getAncestors(trees: Array,config: Object): Object

参数:

trees 树结构数据列表

config 配置 示例:{id: 'id', children: 'children'}

返回值:

[{id: [root, ..., parent2, parent1, node]}, ...]


## 查找所有叶子节点

Expand Down Expand Up @@ -325,7 +338,7 @@ removeNode(trees: Array,config: Object,targetNodeId: any): void


## 排序
sort(treestrees: Array,config: Object,callback: Function): void
sort(trees: Array,config: Object,callback: Function): void

参数:

Expand All @@ -343,8 +356,13 @@ sort(treestrees: Array,config: Object,callback: Function): void

如果非必要,建议列表转树前排序。


# 版本说明

## 0.2.0

新增获取所有节点祖籍函数

## 0.1.0:

遍历函数 (forEach, foreach) 新增扩展设置参数,支持从叶子节点开始遍历
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cut-tree",
"version": "0.1.0",
"version": "0.2.0",
"author": "zhangyuze",
"license": "MIT",
"description": "Tree structure data tool",
Expand All @@ -12,6 +12,9 @@
"url": "https://github.com/zhangyuge7/cut-tree/issues"
},
"keywords": [
"cut tree",
"js处理树结构工具库",
"js tree",
"tree util",
"tree tool"
],
Expand Down
4 changes: 2 additions & 2 deletions src/tree-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ export function useTreeUtil(config = { id: 'id', parentId: 'parentId', children:
}

/**
* 获取祖籍
* 获取全部节点祖籍
* @param {*[]} trees 树结构数据列表
* @returns {Object} {id: [root, ..., parent2, parent1, node]}
* @returns [{id: [root, ..., parent2, parent1, node]}]
*/
function getAncestors(trees) {
const result = {}
Expand Down
4 changes: 2 additions & 2 deletions src/tree-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ export function sort(trees,config,callback){
}

/**
* 获取祖籍
* 获取全部节点祖籍
* @param {*[]} trees 树结构数据列表
* @param {*} config 配置 示例:{id:'id', children: 'children'}
* @returns {Object} {id: [root, ..., parent2, parent1, node]}
* @returns {Object} [{id: [root, ..., parent2, parent1, node]}]
*/
export function getAncestors(trees,config){
const result = {}
Expand Down

0 comments on commit c0baada

Please sign in to comment.