JSPM

  • Created
  • Published
  • Downloads 516652
  • Score
    100M100P100Q239817F
  • License MIT

Package Exports

  • @antv/util
  • @antv/util/esm/index.js
  • @antv/util/lib
  • @antv/util/lib/dom/create-dom
  • @antv/util/lib/dom/create-dom.js
  • @antv/util/lib/dom/modify-css
  • @antv/util/lib/dom/modify-css.js
  • @antv/util/lib/index.js
  • @antv/util/lib/lodash/deep-mix
  • @antv/util/lib/lodash/deep-mix.js
  • @antv/util/lib/lodash/mix
  • @antv/util/lib/lodash/mix.js
  • @antv/util/lib/matrix
  • @antv/util/lib/matrix/index.js
  • @antv/util/lib/matrix/transform
  • @antv/util/lib/matrix/transform.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@antv/util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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.