# @antv/util

> @antv/util

Latest version **3.3.11** (published 2025-07-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @antv/util
pnpm add @antv/util
yarn add @antv/util
bun add @antv/util
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.3.11 |
| Published | 2025-07-01 |
| First published | 2018-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 889.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 72 |
| Maintainers | lvisei, freestyle21, soundquiet, elaine.q.10, sturuby, sakuya223, serializedowen, xdzhao, yangzhanmei, wjgogogo, leungwensen, dori, iaaron, yard, simaq, dxq613, intchous, susan_ann, jinke.li, lzxue, army8735, atool, baizn, dengfuping, neoddish, jeffy2012, zqlu, afc163, pomelo-nwu, kopiluwaky, ccnuzindex, panyuqi, bubkoo, zengyue, kasmine, boyu.zlj, l1ud0ngq1, newbyvector, winniexing, chenluli, kn9117, xdddst, semious2020, esora, nadia_liu, bbsqq, mxz96102, openwayne, pearmini, pddpd, yiqianyao, zhanba, cxxxxxn, laixingui.lxg, susiwen8, yanxiong, zeyuwang, rainy25ghz, zhangjunjie-loki, flash1, yisi.wang, dreammy23, biupiubiupiu, basketduck, xuying1027, banxuan, bqxbqxbqx, duxinyue023, wang1212, xcf(-_-), boyyangzai, siqishen, interstellarmt, moayuisuda |
| Keywords | util, antv |

## Links

- npm: https://www.npmjs.com/package/@antv/util
- Repository: https://github.com/antvis/util
- Homepage: https://github.com/antvis/util#readme
- Issues: https://github.com/antvis/util/issues
- npm.io page: https://npm.io/package/@antv/util

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.3.1
- [gl-matrix](https://npm.io/package/gl-matrix.md) ^3.3.0
- [fast-deep-equal](https://npm.io/package/fast-deep-equal.md) ^3.1.3

## 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

- 3.3.11 (latest) — 2025-07-01
- 1.0.6-beta.2 (beta) — 2018-06-21
- 3.3.10 — 2024-09-19
- 3.3.10-beta.0 — 2024-09-19
- 3.3.9 — 2024-09-19
- 3.3.8 — 2024-08-07
- 3.3.7 — 2024-02-27
- 3.3.6 — 2024-01-17
- 3.3.5 — 2023-10-07
- 3.3.4 — 2023-07-25
- 3.3.3 — 2023-07-25
- 3.3.2 — 2022-12-13
- 3.3.1 — 2022-11-04
- 3.3.0 — 2022-09-16
- 3.2.5 — 2022-09-01
- … 56 more at https://npm.io/package/@antv/util/versions

## README

<h1 align="center">@antv/util</h1>

<div align="center">

AntV 底层依赖的工具库，包含有所有的 util 纯函数，**不建议在自己业务中使用**，避免因为迭代过程的 Break Change 给您带来维护成本。

[![Build Status](https://github.com/antvis/util/workflows/build/badge.svg)](https://github.com/antvis/util/actions)
[![npm Version](https://img.shields.io/npm/v/@antv/util.svg)](https://www.npmjs.com/package/@antv/util)
[![npm Download](https://img.shields.io/npm/dm/@antv/util.svg)](https://www.npmjs.com/package/@antv/util)
[![npm License](https://img.shields.io/npm/l/@antv/util.svg)](https://www.npmjs.com/package/@antv/util)

</div>


## ✨ 特性

- **轻量级**：按需实现代码逻辑，尽可能的减少包大小，目前约 `12kb`；在 lodash 未优化包大小之前，不要在 AntV 中使用 lodash。
- **工具丰富**：包含了不同类别的函数上百种。
- **可视化**：特化工具可视化中使用的颜色、形状、路径、向量、矩阵等方向的功能。


## 📦 安装

```bash
$ npm install @antv/util
```

## 🔨 上手

```ts
import { path2String, path2Array } from '@antv/util';

path2String([
  ['M', 10, 10],
  ['L', 100, 100],
  ['l', 10, 10],
  ['h', 20],
  ['v', 20],
]); 
// ----> 'M10 10L100 100l10 10h20v20'

path2Array('M10 10L100 100l10 10h20v20');
/**
 *  ------->
 * [
 *  ['M', 10, 10],
 *  ['L', 100, 100],
 *  ['l', 10, 10],
 *  ['h', 20],
 *  ['v', 20],
 * ]
 */
```


## 📎 API

- [color（颜色）](./docs/api/color.md) - 颜色格式转化、g 渐变转化 css 渐变等
- [dom（元素）](./docs/api/dom.md) - 基础和 css 添加
- [math（数学）](./docs/api/math.md) - 基础数学计算，包含判断点是否在两个点的线段上、判断点十分在多变形内等
- [matrix（矩阵）](./docs/api/matrix.md) - 向量及矩阵计算方法
- [path（图形）](./docs/api/path.md) - 图形绘画计算方法，包含转换、几何计算等
- [lodash（通用方法）](./docs/api/lodash.md) - util 内置 lodash 通用方法，并添加了更多针对 AntV 的方法工具。


## 🚥 原则

- util 只有一个 npm 包，按照目录来组织不同类型的方法，避免 monorepo 互相依赖。
- 内容和 AntV 强相关，避免做和 lodash 等相同的工具库。
- 不使用的方法，及时删除，并保持新增方法可以按需引入。
- 保持单元测试、文档的完整性。
- 旧版本不维护，如果 AntV 技术栈的旧版本需要迭代，请升级到 v3。


## 📮 贡献

```bash
$ git clone git@github.com:antvis/util.git

$ cd util

$ npm i

$ npm t
```

写完代码之后，提交 PR 即可。


## License

MIT@[AntV](https://github.com/antvis).

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