npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vtils

v4.128.0

Published

一个面向业务的 JavaScript/TypeScript 实用程序库。

Downloads

5,874

Readme

vtils Test Coverage

一个面向业务的 JavaScript/TypeScript 实用程序库。

文档:https://fjc0k.github.io/vtils/v4/

测试报告:https://fjc0k.github.io/vtils/v4-coverage/

import { md5 } from 'vtils'

console.log(md5('龙'))
// => 682570a229cbd3d67e76ad99b3152060

特性

安装

# 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

使用

在 NodeJS 中使用

// 基础工具库
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 中使用

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 中使用

Deno 下暂只支持基础工具库。

// 基础工具库
import {
  wait,
  isNumber,
  EventBus,
  base64Encode,
} from 'https://cdn.skypack.dev/[email protected]'

自定义打包

你可在本地或 https://labs.play-with-docker.com/ 上运行下面的命令,然后打开 http://localhost:9099,接着选择你需要的工具,最后点击开始打包,等待请求执行完成后即可获取仅包含选中工具的 js 代码以及对应的类型定义。

docker run --rm -p 9099:9099 jayfong/vtils

许可

Jay Fong (c) MIT