# hysj-utils

> 旨在提供一系列日常常用工具函数，为大家工作带来便利，后续仓库会经常进行维护

Latest version **1.0.4** (published 2022-08-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install hysj-utils
pnpm add hysj-utils
yarn add hysj-utils
bun add hysj-utils
```

## 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.4 |
| Published | 2022-08-12 |
| First published | 2022-04-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | huyansijun |
| Maintainers | huyansijun |
| Keywords | utils, 工具函数, 防抖, 节流, 异常处理, 心脏复苏, 去重, 数组对象去重, 数组转树结构 |

## Links

- npm: https://www.npmjs.com/package/hysj-utils
- Repository: git@gitee.com:huyan-sijun/hysj-utils
- npm.io page: https://npm.io/package/hysj-utils

## Recent versions

- 1.0.4 (latest) — 2022-08-12
- 1.0.3 — 2022-05-10
- 1.0.2 — 2022-04-08
- 1.0.1 — 2022-04-08
- 1.0.0 — 2022-04-08

## README

# hy-utils
旨在提供一系列日常常用工具函数，为大家工作带来便利，后续仓库会经常进行维护

## 去重
### removeDuplication
removeDuplication 提供一组数组去重的方法

#### basicsRemoveDuplication
· 简单类型数组去重

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `array`        | 仅包含基础数据类型的数组        |

#### complexRemoveDuplication
· 数组对象去重

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `array`        | 数组对象                       |
| `key`         | 以对象那个属性进行去重            |

## 防抖
### debounce
debounce防抖函数 对于高频触发的事件使用防抖可以做到在事件停止执行n秒后执行

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `func`        | 回调函数              |
| `delay`         | 事件执行结束后多久触发 默认200ms  |

## 节流
### throttle
throttle节流函数 对于高频触发的事件使用节流可以做到在事件高频触发的过程中每隔n秒仅执行一次

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `func`        | 回调函数              |
| `delay`         | 事件执行结束后多久触发 默认200ms  |

## 数组排序
### basicsSort
basicsSort基本数组排序

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `array`        | 排序数组             |
| `type`         | 排序类型 'number', 'date'或不传 |
| `order`         | 排序方式 默认为升序 'desc' 为降序 |


## 清除冗余数据
### clearObj
· 清除对象每一项为undefined 或 null的属性

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `obj`        | 对象                       |

### clearArr
· 清除数组对象每一项为undefined 或 null的属性

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `array`        | 数组对象                       |

## 异步错误重试
### cardiacResuscitation 
cardiacResuscitation是一个异步重试函数 提供错误重新执行机制

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `func`        | 返回Promise的函数              |
| `time`         | 错误之后多久重试一次 默认500ms  |
| `times`       | 重试的次数 （不填默认无限重试）  |

## 数组结构转树结构

### tranListToTreeData

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `list`        | 数组              |
| `rootValue`         | 根节点的父唯一标识  |parentKey
| `option`       | 对象  |

- option

| 参数          | 描述                            |
| ------------- | ---------------------------    |
| `key`        | 本级唯一标识 默认 id           |
| `parentKey`    | 本级父唯一标识 默认 pId  |

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