{"name":"vtils","version":"4.131.0","keywords":["util","utils","lodash"],"author":{"url":"https://github.com/fjc0k","name":"Jay Fong","email":"fjc0kb@gmail.com"},"license":"MIT","_id":"vtils@4.131.0","maintainers":[{"name":"funch","email":"fjc0kb@gmail.com"}],"homepage":"https://github.com/fjc0k/vtils#readme","bugs":{"url":"https://github.com/fjc0k/vtils/issues"},"dist":{"shasum":"042bb4e1e538395020c2b94cd833932da9dd0543","tarball":"http://registry-npm.ywwl.com/vtils/download/vtils-4.131.0.tgz","fileCount":544,"integrity":"sha512-xdtx5l+9OmECYoaA2nhQnfxPnn1AuKo+Rz656pinpq4RvP+nYix7bLUEBbPxQzVrJuu0GagkzL7nIb2Y8zDokQ==","signatures":[{"sig":"MEUCIQCs0vwbndEF/IxQF7xz8IdT3/HeK5+3u791Q0fI2FWNWwIgVS9JVTZ3rZS2BC68KxQZGGnr08hxd4dxz4T3rOin+Js=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1302817,"size":226321,"noattachment":false,"key":"/vtils/-/vtils-4.131.0.tgz"},"main":"_cjs/utils/index.js","type":"module","types":"utils/index.d.ts","module":"utils/index.js","exports":{".":{"types":"./utils/index.d.ts","import":"./utils/index.js","require":"./_cjs/utils/index.js"},"./x":{"types":"./x/index.d.ts","import":"./x/index.js","require":"./_cjs/x/index.js"},"./mp":{"types":"./mp/index.d.ts","import":"./mp/index.js","require":"./_cjs/mp/index.js"},"./dev":{"types":"./dev/index.d.ts","import":"./dev/index.js","require":"./_cjs/dev/index.js"},"./vae":{"types":"./vae/index.d.ts","import":"./vae/index.js","require":"./_cjs/vae/index.js"},"./date":{"types":"./date/index.d.ts","import":"./date/index.js","require":"./_cjs/date/index.js"},"./react":{"types":"./react/index.d.ts","import":"./react/index.js","require":"./_cjs/react/index.js"},"./types":"./types/index.d.ts","./utils":{"types":"./utils/index.d.ts","import":"./utils/index.js","require":"./_cjs/utils/index.js"},"./regexp":{"types":"./regexp/index.d.ts","import":"./regexp/index.js","require":"./_cjs/regexp/index.js"},"./validator":{"types":"./validator/index.d.ts","import":"./validator/index.js","require":"./_cjs/validator/index.js"},"./package.json":"./package.json"},"gitHead":"daa827b8e9f8ed6487cf3347fb44a70246d93506","_npmUser":{"name":"funch","email":"fjc0kb@gmail.com"},"repository":{"url":"git+https://github.com/fjc0k/vtils.git","type":"git"},"_npmVersion":"8.19.4","description":"一个面向业务的 JavaScript/TypeScript 实用程序库。","directories":{},"resolutions":{"typescript":"^5.4.5","@microsoft/api-extractor":"^7.46.2","@microsoft/api-documenter":"^7.25.2"},"sideEffects":["./validator/yup.js"],"_nodeVersion":"16.20.2","dependencies":{"cuid":"^2.1.8","uuid":"^8.3.2","gcoord":"^0.3.2","nanoid":"^3.1.20","ioredis":"^4.22.0","date-fns":"^3.3.1","toposort":"^2.0.2","benchmark":"^2.1.4","react-use":"^17.2.1","cli-table3":"^0.6.0","lodash-uni":"^1.2.0","tough-cookie":"^4.0.0","property-expr":"^2.0.4","@babel/runtime":"^7.12.18","@types/ioredis":"^4.19.4","fast-xml-parser":"^3.18.0","@types/benchmark":"^2.1.0","decimal.js-light":"^2.5.1","@types/tough-cookie":"^4.0.0","@paralleldrive/cuid2":"^2.2.2","typed-query-selector":"^2.6.0","tough-cookie-redisstore":"^0.0.4"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/vtils_4.131.0_1747410617470_0.6964216663611749","host":"s3://npm-registry-packages-npm-production"},"readme":"# vtils ![Test](https://github.com/fjc0k/vtils/workflows/Test/badge.svg?branch=master) <a href=\"https://fjc0k.github.io/vtils/v4-coverage/\">![Coverage](https://codecov.io/gh/fjc0k/vtils/branch/master/graph/badge.svg)</a>\n\n一个面向业务的 JavaScript/TypeScript 实用程序库。\n\n> 文档：[https://fjc0k.github.io/vtils/v4/](https://fjc0k.github.io/vtils/v4/)\n>\n> 测试报告：[https://fjc0k.github.io/vtils/v4-coverage/](https://fjc0k.github.io/vtils/v4-coverage/)\n\n```ts\nimport { md5 } from 'vtils'\n\nconsole.log(md5('龙'))\n// => 682570a229cbd3d67e76ad99b3152060\n```\n\n---\n\n<!-- TOC depthFrom:2 -->\n\n- [特性](#特性)\n- [安装](#安装)\n- [使用](#使用)\n  - [在 NodeJS 中使用](#在-nodejs-中使用)\n  - [在 Taro 3 中使用](#在-taro-3-中使用)\n  - [在 Deno 中使用](#在-deno-中使用)\n  - [自定义打包](#自定义打包)\n- [许可](#许可)\n\n<!-- /TOC -->\n\n## 特性\n\n- **🙅‍♀️ 拒绝重复**：基于社区优质程序库（[Lodash](https://lodash.com/)、[date-fns](https://date-fns.org/)、[react-use](https://github.com/streamich/react-use#readme)、[type-fest](https://github.com/sindresorhus/type-fest#readme)、[ts-essentials](https://github.com/krzkaczor/ts-essentials#readme)、[yup](https://github.com/jquense/yup) 等），补充常用业务代码。\n\n- **🌸 精致优雅**：为每一个工具都添加了注释、测试，不看文档亦可直接使用。\n\n- **🌈 面向未来**：使用 [TypeScript](https://www.typescriptlang.org/) 编写，支持 [Tree Shaking](https://webpack.js.org/guides/tree-shaking/)、[ECMAScript Modules](https://nodejs.org/api/esm.html)，也可以在 [Taro 3](https://taro.js.org/)、 [Deno](https://deno.land/) 中使用。\n\n## 安装\n\n```bash\n# npm\nnpm i vtils\n\n# yarn\nyarn add vtils\n\n# pnpm\npnpm add vtils\n```\n\n若在国内，推荐安装 [tbify](https://github.com/fjc0k/tbify#readme) 使用淘宝镜像加速：\n\n```bash\n# npm\ntnpm i vtils\n\n# yarn\ntyn add vtils\n\n# pnpm\ntpm add vtils\n```\n\n## 使用\n\n### 在 NodeJS 中使用\n\n```ts\n// 基础工具库\nimport { wait, isNumber, EventBus, base64Encode } from 'vtils'\n\n// 日期时间工具库\nimport { formatRelative, subDays, zhCN } from 'vtils/date'\n\n// React 工具库\nimport { useClassName, useToggle, useScrollLoadMore } from 'vtils/react'\n\n// 验证工具库\nimport { yup } from 'vtils/validator'\n\n// 类型工具库\nimport { OmitStrict, LiteralUnion, PartialDeep } from 'vtils/types'\n\n// 小程序工具库\nimport { getTopBarInfo, navigatePageTo, redirectPageTo } from 'vtils/mp'\n```\n\n详细用法见文档：[https://fjc0k.github.io/vtils/v4/](https://fjc0k.github.io/vtils/v4/)。\n\n### 在 Taro 3 中使用\n\n在 [Taro 3](https://taro.js.org/) 中使用前需要修改 Webpack 配置，在 `config/index.js` 中的 `mini` 字段下设置：\n\n```ts\nmini: {\n  webpackChain(config) {\n    // 该插件会影响 resolve.extensions 的表现，删去\n    config.resolve.plugins.delete('MultiPlatformPlugin')\n    // 支持 .taro.js 后缀\n    config.resolve.extensions.prepend('.taro.js')\n  },\n}\n```\n\n然后，就可以愉快地使用了：\n\n```ts\n// React 工具库\nimport { useSearchParam } from 'vtils/react'\n\n// 小程序工具库\nimport { useTopBarInfo } from 'vtils/mp'\n\nexport default function () {\n  const id = +useSearchParam('id')!\n  const topBarInfo = useTopBarInfo()\n  // ...\n}\n```\n\n### 在 Deno 中使用\n\n[Deno](https://deno.land/) 下暂只支持基础工具库。\n\n```ts\n// 基础工具库\nimport {\n  wait,\n  isNumber,\n  EventBus,\n  base64Encode,\n} from 'https://cdn.skypack.dev/vtils@4.138.0'\n```\n\n### 自定义打包\n\n你可在本地或 [https://labs.play-with-docker.com/](https://labs.play-with-docker.com/) 上运行下面的命令，然后打开 `http://localhost:9099`，接着选择你需要的工具，最后点击开始打包，等待请求执行完成后即可获取仅包含选中工具的 js 代码以及对应的类型定义。\n\n```bash\ndocker run --rm -p 9099:9099 jayfong/vtils\n```\n\n## 许可\n\nJay Fong (c) MIT\n","publish_time":1747410617784,"_cnpm_publish_time":1747410617784,"dist-tags":{"beta":"2.27.0-beta.0","latest":"4.138.0","next":"4.34.3-beta.0"}}