# @yarn-tool/normalize-deps-value

> Normalize dependency values to standardized semver format / 將依賴值正規化為標準化的 semver 格式

Latest version **2.0.9** (published 2026-09-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install @yarn-tool/normalize-deps-value
pnpm add @yarn-tool/normalize-deps-value
yarn add @yarn-tool/normalize-deps-value
bun add @yarn-tool/normalize-deps-value
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.9 |
| Published | 2026-09-06 |
| First published | 2022-08-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 40.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | yarn, yarn-tool, npm, lerna, workspaces, pkg, dependencies, monorepo, yarnlock, node-modules, packages, package, create-by-yarn-tool |

## Links

- npm: https://www.npmjs.com/package/@yarn-tool/normalize-deps-value
- Repository: https://github.com/bluelovers/ws-yarn-workspaces
- Homepage: https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@yarn-tool/normalize-deps-value#readme
- Issues: https://github.com/bluelovers/ws-yarn-workspaces/issues
- npm.io page: https://npm.io/package/@yarn-tool/normalize-deps-value

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) >=2.8.1
- [@lazy-node/semver-ampersand](https://npm.io/package/@lazy-node/semver-ampersand.md) ^3.0.11
- [@yarn-tool/npm-package-arg-util](https://npm.io/package/@yarn-tool/npm-package-arg-util.md) ^2.0.8

## Recent versions

- 2.0.9 (latest) — 2026-09-06
- 2.0.8 — 2026-04-26
- 2.0.7 — 2026-04-26
- 2.0.6 — 2026-03-09
- 2.0.4 — 2026-03-02
- 2.0.3 — 2025-09-07
- 2.0.2 — 2024-05-03
- 2.0.1 — 2024-02-28
- 2.0.0 — 2023-10-10
- 1.0.11 — 2022-12-09
- 1.0.10 — 2022-11-14
- 1.0.9 — 2022-10-28
- 1.0.8 — 2022-10-01
- 1.0.7 — 2022-09-29
- 1.0.6 — 2022-09-27
- … 5 more at https://npm.io/package/@yarn-tool/normalize-deps-value/versions

## README

# @yarn-tool/normalize-deps-value

Normalize dependency values to standardized semver format.
將依賴值正規化為標準化的 semver 格式。

## Features / 功能特點

- Handles edge cases like empty inputs, spaces, and star wildcards / 處理空輸入、空格和星號萬用字元等邊緣情況
- Normalizes complex semver ranges / 正規化複雜的 semver 範圍
- Converts npm-package-arg results to standardized dependency values / 將 npm-package-arg 結果轉換為標準化的依賴值

## Install / 安裝

```bash
yarn add @yarn-tool/normalize-deps-value
yarn-tool add @yarn-tool/normalize-deps-value
yt add @yarn-tool/normalize-deps-value
```

## Usage / 使用方式

```typescript
import { normalizeDepsValue, normalizeResultToDepsValue, _getNpaResult } from '@yarn-tool/normalize-deps-value';

// Normalize a dependency value string
// 正規化依賴值字串
normalizeDepsValue('');           // => "*"
normalizeDepsValue(' ');          // => "*"
normalizeDepsValue('*');          // => "*"
normalizeDepsValue('^4.0.0');     // => "^4.0.0"
normalizeDepsValue('>=1.0.0 <2.0.0'); // => ">=1.0.0 <2.0.0"
normalizeDepsValue('lodash@^4.0.0'); // => "^4.0.0"

// Parse and normalize npm-package-arg result
// 解析並正規化 npm-package-arg 結果
const result = _getNpaResult('^4.0.0');
normalizeResultToDepsValue(result); // => "^4.0.0"
```

## API / API 文件

### `normalizeDepsValue(value: string): string`

Normalizes a dependency value string to standard format.
將依賴值字串正規化為標準格式。

**Parameters / 參數:**
- `value` - The dependency value to normalize / 要正規化的依賴值

**Returns / 返回:**
- Normalized dependency value / 正規化的依賴值

### `normalizeResultToDepsValue(result): string`

Converts an npm-package-arg result to a dependency value string.
將 npm-package-arg 結果轉換為依賴值字串。

### `_getNpaResult(value: string): IResult`

Parses a value string into an npm-package-arg result using multiple strategies.
使用多種策略將值字串解析為 npm-package-arg 結果。

## Related / 相關專案

- [@yarn-tool/npm-package-arg-util](../npm-package-arg-util) - npm-package-arg utilities
- [@yarn-tool/npa-to-deps](../npa-to-deps) - Convert npm-package-arg results to dependency objects

## License / 授權

ISC

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