# @baiwusanyu/utils-normalize

> ## Function

Latest version **1.1.2** (published 2024-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @baiwusanyu/utils-normalize
pnpm add @baiwusanyu/utils-normalize
yarn add @baiwusanyu/utils-normalize
bun add @baiwusanyu/utils-normalize
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2024-12-12 |
| First published | 2023-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | baiwusanyu-c |
| Maintainers | baiwusanyu |
| Keywords | typescript, javascript, utils, vue, vue3, vite, react |

## Links

- npm: https://www.npmjs.com/package/@baiwusanyu/utils-normalize
- Repository: https://github.com/baiwusanyu-c/bwsy-utils
- Homepage: https://github.com/baiwusanyu-c
- Issues: https://github.com/baiwusanyu-c/bwsy-utils/issues
- npm.io page: https://npm.io/package/@baiwusanyu/utils-normalize

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2024-12-12
- 1.1.1 — 2024-12-12
- 1.1.0 — 2024-12-12
- 1.0.18 — 2023-12-28
- 1.0.17 — 2023-12-28
- 1.0.16 — 2023-09-02
- 1.0.15 — 2023-08-15
- 1.0.14 — 2023-07-08
- 1.0.13 — 2023-05-25
- 1.0.12 — 2023-05-10
- 1.0.11 — 2023-05-08
- 1.0.10 — 2023-05-08
- 1.0.9 — 2023-05-07
- 1.0.8 — 2023-05-04

## README

# @baiwusanyu/utils-normalize

## Function

### normalizePath

统一化路径，抹平win与 mac、linux 路径差异

| 参数   | 参数类型     | 默认值     | 说明      |
|------|----------|---------|---------|
| path | `string` | `-`     | 需要统一的路径 |

| 返回值 | 返回类型      | 说明 |
|-----|-----------|---|
| res | `string` | 统一化路径 |

### normalizeEllipsis

统一化文本过长，缩略展示

| 参数       | 参数类型     | 默认值  | 说明                    |
|----------|----------|------|-----------------------|
| str      | `string` | `""` | 需要统一的路径               |
| limitLen | `number` | `24` | 限制的文本字符数量，超过的部分会被省略显示 |

| 返回值 | 返回类型      | 说明 |
|-----|-----------|---|
| res | `string` | 缩略展示结果 |

### normalizeSizeUnits

统一化存储单位，字节转化为英文缩写`bytes`, `KB`, `MB`, `GB`

| 参数       | 参数类型     | 默认值  | 说明                    |
|----------|----------|------|-----------------------|
| bytes      | `number` | `-`  | 需要转换的字节大小             |


| 返回值 | 返回类型 | 说明 |
|-----|-----------|---|
| res | `string` | 转化后的字节字符串 |

### normalizeNum2Comma

统一化数字，将数字转化为逗号分隔的字符串

| 参数       | 参数类型     | 默认值 | 说明      |
|----------|----------|-----|---------|
| num      | `number` | `-` | 需要转换的数字 |
| decimal      | `number` | `6` | 转换精度    |

| 返回值 | 返回类型      | 说明 |
|-----|-----------|---|
| res | `string` | 转化后的数字字符串 |

### normalizeVarStrEmpty

将虚值或字符串 `'undefined'` 、 `'null'` 转化为空字符串

| 参数       | 参数类型     | 默认值 | 说明       |
|----------|----------|-----|----------|
| str      | `string` | `-` | 需要转换的字符串 |

| 返回值 | 返回类型      | 说明      |
|-----|-----------|---------|
| res | `string` | 返回空字符串 `''` |

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