# @jkun/utils

> 提供常用的函数方法

Latest version **0.2.2** (published 2023-03-16) · 0 weekly downloads

## Install

```sh
npm install @jkun/utils
pnpm add @jkun/utils
yarn add @jkun/utils
bun add @jkun/utils
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2023-03-16 |
| First published | 2023-02-13 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | guojikun |
| Keywords | javascript, utils, front-end, tool |

## Links

- npm: https://www.npmjs.com/package/@jkun/utils
- npm.io page: https://npm.io/package/@jkun/utils

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2023-03-16
- 0.2.1 — 2023-03-03
- 0.2.0 — 2023-03-03
- 0.1.0 — 2023-02-13

## README

# Utils 工具函数

提供常用的函数方法


## Array 方法

|方法名| 描述| 参数| 返回值|
|---|---|---|---|
|sum| 求和| `(Array<T extends object | number>)` | `number` |
|average| 求平均值| `(Array<number>)` | `number` |
|min| 最小值| `(Array<number>)` | `number` |
|max| 最大值| `(Array<number>)` | `number` |
|isEmpty| 是否为空| `(Array<any>)` | `boolean` |


## Type

获取变量的类型 `Type.is()`，Type是一个class且只有静态方法

|方法名| 描述| 参数| 返回值|
|---|---|---|---|
|is| 求和| `(<T>)` | `string` |
|isNull| 是否是 null 类型| `(any)` | `boolean` |
|isString | 是否是 string 类型| `(any)` | `boolean` |
|isBoolean| 是否是 boolean 类型| `(any)` | `boolean` |
|isObject| 是否是 object 类型| `(any)` | `boolean` |
|isArray| 是否是 array 类型| `(any)` | `boolean` |
|isFunction| 是否是 function 类型| `(any)` | `boolean` |
|isReg| 是否是 regExp 类型| `(any)` | `boolean` |
|isNumber| 是否是 number 类型| `(any)` | `boolean` |
|isDate| 是否是 date 类型| `(any)` | `boolean` |
|average| 是否是 null 类型| `(any)` | `boolean` |
|average| 是否是 null 类型| `(any)` | `boolean` |
|average| 是否是 null 类型| `(any)` | `boolean` |

## Cookie

cookie 的相关操作

|方法名| 描述| 参数| 返回值|
|---|---|---|---|
|setItem| 设置cookie| `(sKey: string, sValue: string, vEnd?: any, sPath?: string, sDomain?: string, bSecure?: any)` | `boolean` |
|getItem| 获取cookie| `(sKey: string)` | `string | null` |
|removeItem| 移除cookie| `sKey: string, sPath?: string, sDomain?: string)` | `boolean` |
|has| 是否有| `(sKey: string)` | `boolean` |
|keys| 所有cookie的key| `()` | `string[]` |
|clear| 清除所有的cookie| `()` | `avoid` |

## Func

函数相关的方法

|方法名| 描述| 参数| 返回值|
|---|---|---|---|
| debounce | 防抖 | `(func: Function, wait: number = 200, immediate: boolean = false)` | `function` |
| throttle | 节流 | `(func: Function, wait: number = 200, type: number = 2)` | `function` |

## String

字符串处理相关的方法


|方法名| 描述| 参数| 返回值|
|---|---|---|---|
| trim| 移除前后的空格| `(val: string)` | `string` |
| trimStart| 移除前面的空格| `(val: string)` | `string` |
| trimEnd| 移除后面的空格| `(val: string)` | `string` |
| unicode| 获取字符串的unicode数字| `(val: string)` | `number[]` |
| thousandsSeparator| 千分位分隔符| `(val: string | number)` | `string` |

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