
Product
Introducing Custom Tabs for Org Alerts
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.
一个面向业务的 JavaScript/TypeScript 实用程序库。
import { md5 } from 'vtils'
console.log(md5('龙'))
// => 682570a229cbd3d67e76ad99b3152060
🙅♀️ 拒绝重复:基于社区优质程序库(Lodash、date-fns、react-use、type-fest、ts-essentials、yup 等),补充常用业务代码。
🌸 精致优雅:为每一个工具都添加了注释、测试,不看文档亦可直接使用。
🌈 面向未来:使用 TypeScript 编写,支持 Tree Shaking、ECMAScript Modules,也可以在 Taro 3、 Deno 中使用。
# npm
npm i vtils
# yarn
yarn add vtils
# pnpm
pnpm add vtils
若在国内,推荐安装 tbify 使用淘宝镜像加速:
# npm
tnpm i vtils
# yarn
tyn add vtils
# pnpm
tpm add vtils
// 基础工具库
import { wait, isNumber, EventBus, base64Encode } from 'vtils'
// 日期时间工具库
import { formatRelative, subDays, zhCN } from 'vtils/date'
// React 工具库
import { useClassName, useToggle, useScrollLoadMore } from 'vtils/react'
// 验证工具库
import { yup } from 'vtils/validator'
// 类型工具库
import { OmitStrict, LiteralUnion, PartialDeep } from 'vtils/types'
// 小程序工具库
import { getTopBarInfo, navigatePageTo, redirectPageTo } from 'vtils/mp'
详细用法见文档:https://fjc0k.github.io/vtils/v4/。
在 Taro 3 中使用前需要修改 Webpack 配置,在 config/index.js 中的 mini 字段下设置:
mini: {
webpackChain(config) {
// 该插件会影响 resolve.extensions 的表现,删去
config.resolve.plugins.delete('MultiPlatformPlugin')
// 支持 .taro.js 后缀
config.resolve.extensions.prepend('.taro.js')
},
}
然后,就可以愉快地使用了:
// React 工具库
import { useSearchParam } from 'vtils/react'
// 小程序工具库
import { useTopBarInfo } from 'vtils/mp'
export default function () {
const id = +useSearchParam('id')!
const topBarInfo = useTopBarInfo()
// ...
}
Deno 下暂只支持基础工具库。
// 基础工具库
import {
wait,
isNumber,
EventBus,
base64Encode,
} from 'https://cdn.skypack.dev/vtils@4.136.0'
你可在本地或 https://labs.play-with-docker.com/ 上运行下面的命令,然后打开 http://localhost:9099,接着选择你需要的工具,最后点击开始打包,等待请求执行完成后即可获取仅包含选中工具的 js 代码以及对应的类型定义。
docker run --rm -p 9099:9099 jayfong/vtils
Jay Fong (c) MIT
FAQs
一个面向业务的 JavaScript/TypeScript 实用程序库。
The npm package vtils receives a total of 841 weekly downloads. As such, vtils popularity was classified as not popular.
We found that vtils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.