# luo-ergodic-tree

> Ergodic tree

Latest version **1.0.5** (published 2021-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install luo-ergodic-tree
pnpm add luo-ergodic-tree
yarn add luo-ergodic-tree
bun add luo-ergodic-tree
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-12-14 |
| First published | 2019-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | make 2019 by luo |
| Maintainers | luo195289 |

## Links

- npm: https://www.npmjs.com/package/luo-ergodic-tree
- npm.io page: https://npm.io/package/luo-ergodic-tree

## Recent versions

- 1.0.5 (latest) — 2021-12-14
- 1.0.4 — 2021-10-31
- 1.0.3 — 2020-02-28
- 1.0.2 — 2019-09-18
- 1.0.1 — 2019-09-18
- 1.0.0 — 2019-08-31

## README

# Luo-Ergodic-Tree

> Ergodic tree


## Install

```bash
npm install luo-ergodic-tree -S
```

## Usage

```js
示例1
import luoErgodicTree from 'luo-ergodic-tree';
let data = [
  {
    key: '0',
    children: [
      {
        key: '1',
        children: []
      }
    ]
  }
];

let arr = luoErgodicTree(data, 'sn', (item, parent, index, pid) => {
  item.id = 'xxz';
  item.name = 'zzz';
});
console.log(arr);

示例2
import luoErgodicTree from 'luo-ergodic-tree';
let data = [
  {
    key: '0',
    children: [
      {
        key: '1',
        children: []
      }
    ]
  }
];

let arr = luoErgodicTree(data, 'sn', (item, parent, index, pid) => {
  item.id = 'xxz';
  item.name = 'zzz';
}, true);
console.log(arr);

示例3
import luoErgodicTree from 'luo-ergodic-tree';
let data = [
  {
    key: '0',
    children: [
      {
        key: '1',
        children: []
      }
    ]
  }
];

let arr = luoErgodicTree(data, 'sn', (item, parent, index, pid) => {
  item.id = 'xxz';
  item.name = 'zzz';
  if (!item.id) return undefined;
  return item;
}, true);
console.log(arr);
```

## Props 

| 参数类型 | 说明 |
| ---------- | ----------- |
| Array | 要解析的树型数组 |
| String | 树的children名 |
| Function | 解析第一层时的回调 |
| Boolean | 是否在解析前把原始数据格式化（可选） |
| mode | 模式（可选）1为必需在回调函数里返回值，2为必需在回调函数里返回值并过滤undefined |

回调返回参数说明
| 名称 | 说明 |
| ---------- | ----------- |
| item | 当前节点 |
| parent | 父节点 |
| index | 当前索引 |
| pid | 层次id |

# License

This content is released under the [MIT](http://opensource.org/licenses/MIT) License.

---
_Source: https://npm.io/package/luo-ergodic-tree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
