MCPcopy Index your code
hub / github.com/antvis/util

github.com/antvis/util @3.3.11

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.3.11 ↗ · + Follow
212 symbols 460 edges 220 files 10 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@antv/util

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

Build Status npm Version npm Download npm License

✨ 特性

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

📦 安装

$ npm install @antv/util

🔨 上手

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

🚥 原则

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

📮 贡献

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

$ cd util

$ npm i

$ npm t

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

License

MIT@AntV.

Extension points exported contracts — how you extend this code

RadiusType (Interface)
(no doc)
src/lodash/parse-radius.ts
SegmentProperties (Interface)
(no doc)
src/path/types.ts
RangeType (Interface)
(no doc)
src/lodash/get-range.ts
ParserParams (Interface)
(no doc)
src/path/types.ts
ObjectType (Interface)
(no doc)
src/lodash/pick.ts
PathBBox (Interface)
(no doc)
src/path/types.ts
ObjectType (Interface)
(no doc)
src/lodash/substitute.ts
PathBBoxTotalLength (Interface)
(no doc)
src/path/types.ts

Core symbols most depended-on inside this repo

isArray
called by 30
src/lodash/is-array.ts
isNumber
called by 26
src/lodash/is-number.ts
isEven
called by 22
src/lodash/is-even.ts
isFunction
called by 22
src/lodash/is-function.ts
isOdd
called by 21
src/lodash/is-odd.ts
isString
called by 19
src/lodash/is-string.ts
isNegative
called by 15
src/lodash/is-negative.ts
isNil
called by 15
src/lodash/is-nil.ts

Shape

Function 184
Interface 17
Method 7
Class 4

Languages

TypeScript100%

Modules by API surface

src/path/types.ts8 symbols
src/lodash/cache.ts8 symbols
src/math/is-polygons-intersect.ts7 symbols
src/matrix/transform.ts5 symbols
src/lodash/memoize.ts5 symbols
src/path/util/segment-arc-factory.ts3 symbols
src/path/util/equalize-segments.ts3 symbols
src/path/parser/path-parser.ts3 symbols
src/math/is-point-in-polygon.ts3 symbols
src/lodash/throttle.ts3 symbols
src/lodash/deep-mix.ts3 symbols
src/color/gradient.ts3 symbols

For agents

$ claude mcp add util \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact