{"id":13537252,"url":"https://github.com/fjc0k/vtils","last_synced_at":"2025-05-15T15:08:16.350Z","repository":{"id":33114045,"uuid":"152191761","full_name":"fjc0k/vtils","owner":"fjc0k","description":"一个面向业务的 JavaScript/TypeScript 实用程序库。支持在浏览器、Node.js、小程序、Taro、Deno 下使用。","archived":false,"fork":false,"pushed_at":"2025-03-19T09:07:02.000Z","size":16112,"stargazers_count":253,"open_issues_count":0,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-12T05:06:40.310Z","etag":null,"topics":["deno","javascript","nodejs","typescript","utils","vtils"],"latest_commit_sha":null,"homepage":"https://fjc0k.github.io/vtils/v4/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fjc0k.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-09T05:18:59.000Z","updated_at":"2025-05-06T04:00:22.000Z","dependencies_parsed_at":"2023-01-14T23:24:52.844Z","dependency_job_id":"1a298af9-edf2-417e-b5fa-b8e5685f6e8f","html_url":"https://github.com/fjc0k/vtils","commit_stats":{"total_commits":2111,"total_committers":3,"mean_commits":703.6666666666666,"dds":"0.29417337754618667","last_synced_commit":"3124bb4609ca39ce6daf3cf534f08f66d2d9651c"},"previous_names":[],"tags_count":599,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fvtils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fvtils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fvtils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Fvtils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fjc0k","download_url":"https://codeload.github.com/fjc0k/vtils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","javascript","nodejs","typescript","utils","vtils"],"created_at":"2024-08-01T09:00:56.810Z","updated_at":"2025-05-15T15:08:11.340Z","avatar_url":"https://github.com/fjc0k.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# vtils ![Test](https://github.com/fjc0k/vtils/workflows/Test/badge.svg?branch=master) \u003ca href=\"https://fjc0k.github.io/vtils/v4-coverage/\"\u003e![Coverage](https://codecov.io/gh/fjc0k/vtils/branch/master/graph/badge.svg)\u003c/a\u003e\n\n一个面向业务的 JavaScript/TypeScript 实用程序库。\n\n\u003e 文档：[https://fjc0k.github.io/vtils/v4/](https://fjc0k.github.io/vtils/v4/)\n\u003e\n\u003e 测试报告：[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// =\u003e 682570a229cbd3d67e76ad99b3152060\n```\n\n---\n\n\u003c!-- TOC depthFrom:2 --\u003e\n\n- [特性](#特性)\n- [安装](#安装)\n- [使用](#使用)\n  - [在 NodeJS 中使用](#在-nodejs-中使用)\n  - [在 Taro 3 中使用](#在-taro-3-中使用)\n  - [在 Deno 中使用](#在-deno-中使用)\n  - [自定义打包](#自定义打包)\n- [许可](#许可)\n\n\u003c!-- /TOC --\u003e\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.130.1'\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjc0k%2Fvtils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffjc0k%2Fvtils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjc0k%2Fvtils/lists"}