# @react-kit/util

> ------ 通用工具

Latest version **0.5.5** (published 2019-08-30) · 0 weekly downloads

## Install

```sh
npm install @react-kit/util
pnpm add @react-kit/util
yarn add @react-kit/util
bun add @react-kit/util
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.5 |
| Published | 2019-08-30 |
| First published | 2019-05-10 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yang |
| Maintainers | guccihuiyuan |

## Links

- npm: https://www.npmjs.com/package/@react-kit/util
- npm.io page: https://npm.io/package/@react-kit/util

## Recent versions

- 0.5.5 (latest) — 2019-08-30
- 0.5.4 — 2019-08-30
- 0.5.3 — 2019-08-30
- 0.5.2 — 2019-08-30
- 0.5.1 — 2019-08-30
- 0.5.0 — 2019-05-14
- 0.4.0 — 2019-05-10

## README

# react-kit/util
------
通用工具

## TreeService
> * 可配置
> * 处理数组与树之间的转换

### 配置参数
```
export interface TreeConfig {
    /**
     * 根ID
     */
    rootParentId?: string;
    /**
     * 编号项名
     */
    idMapName?: string;
    /**
     * 父编号项名
     */
    parentIdMapName?: string;
    /**
     * 扁平后数组的父数据项名
     */
    parentMapName?: string;
    /**
     * 源数据子项名
     */
    childrenMapName?: string;
    /**
     * 是否移除children
     */
    clearChildren?: boolean;
    /**
     * 深度项名
     */
    deepMapName?: string;


    /**
     * 回调方法
     * @param item
     */
    cb?: (item: any, parent?: any, deep?: number) => void;
}
```

### 示例(传入参数可点击方法进去查看)
```
import { TreeService } from '@react-kit/util';

// 初始化，可传入配置
export const treeService = new TreeService();

// 树转换成数组
treeService.treeToArr();

// 数组转换成树
treeService.arrToTree();

// 遍历树
treeService.visitTree();
```

---
_Source: https://npm.io/package/@react-kit/util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
