https://github.com/phphe/tree-helper
https://github.com/phphe/tree-helper
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/phphe/tree-helper
- Owner: phphe
- License: mit
- Created: 2017-04-05T13:12:15.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-15T14:58:07.000Z (about 1 year ago)
- Last Synced: 2024-11-07T22:13:33.107Z (7 months ago)
- Language: JavaScript
- Size: 204 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# tree-helper
js functions, just import needed functions.
js 方法库, 按需使用```sh
// install
npm install tree-helper -S
```
### usage 使用
```
import {function1, function2} from 'tree-helper'```
### some functions. pls check source to get more 常用方法, 请查看源码获取更多方法
```js
// depth first search; 深度优先遍历
depthFirstSearch(obj, handler, childrenKey = 'children', reverse)
- handler(item, i, parent)
return false // break loop
return 'skip children' // skip children
return 'skip siblings' // skip siblings
// breadth first search; 广度优先遍历
breadthFirstSearch(obj, handler, childrenKey = 'children', reverse)
- handler(item, i, parent)
return false // break loop
return 'skip children' // skip children
return 'skip siblings' // skip siblings
```