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 🙏

© 2026 – Pkg Stats / Ryan Hefner

df-w-tools

v1.0.0

Published

```shell npm i df-w-tools@latest ```

Readme

工具组件

安装

npm i df-w-tools@latest

使用

import DfTools from 'df-w-tools'
DfTools.wind.vectorToSpeed(uu, vv)

注册自己的插件

  1. 仅在当前页使用
import DfTools from 'df-w-tools'
class AddPlugin {
    static add(a: number, b: number) {
        return a + b
    }
}
DfTools.register('add', AddPlugin)

const sum = DfTools.get<typeof AddPlugin>('addX').add(a.value, b.value)
  1. 全局注册插件
// useMul.ts
import DfTools, { createAccessor } from './df-tools'

class MulPlugin {
    static mul(a: number, b: number) {
        return a * b
    }
}

DfTools.register('mul', MulPlugin)

export const useMul = createAccessor<typeof MulPlugin>('mul')
<!-- Mul.vue -->
<script setup lang="ts">
import { useMul } from './useMul'
const res = useMul().mul(1, 2)
</script>

内置插件

内置插件的使用方法:

import DfTools from './DfTools'
const winD = DfTools.wind.vectorToDegrees(uu, vv)
// DfTools.wep.getName(4, 1)
// DfTools.file.downloadFile('/path/to/file', 'filename.txt')
// DfTools.color.toRgba('#ffffff') -> 'rgba(255, 255, 255, 1)'

wind 风

  • vectorToSpeed(uMs: number, vMs: number, unNum?: number): number
    • uv转风速
  • vectorToDegrees(uMs: number, vMs: number, unNum?: number): number
    • uv转风向

wep 天气现象

  • getSomethingOnWep(wepCode: number, key: string | string[], isYb?: boolean): (string | undefined)[]
    • 获取天气现象code的 名称(name -> '晴'), key值(key -> 'QING')
  • getName(wep: number, wep2?: number, isYb?: boolean): string
    • 获取天气现象code的名称(wep2是补充code, 例如:wep=4, wep2=1 -> '雷阵雨转多云')

file 文件

  • downloadFile(filePath: string, filename?: string): void
  • downloadBlob(blob: Blob, filename?: string): void

color 颜色

  • hex2rgba(hex: string): string
  • hex2hsl(hex: string): string
  • rgba2hex(rgba: string): string
  • rgba2hsl(rgba: string): string
  • hsl2rgba(hsl: string): string
  • hsl2hex(hsl: string): string
  • toRgba(color: string): string
  • toHsl(color: string): string
  • toHex(color: string): string

regexp 正则

每个正则都有自己匹配的isXxx方法

// DfTools.regexp.contact.contactRegExp.MOBILE_CN -> RegExp
// DfTools.regexp.contact.isMobileCN(phone.value) -> boolean

base: 基础字符类正则

  • NUMBER: 数字
  • INTEGER: 整数
  • FLOAT: 浮点数
  • ALPHABET: 字母
  • ALPHABET_LOWER: 小写字母
  • ALPHABET_UPPER: 大写字母
  • ALPHANUMERIC: 字母数字组合
  • ALPHANUMERIC_UNDERSCORE: 字母数字下划线组合
  • CHINESE: 中文
  • CHINESE_NAME: 中文姓名

contact: 联系方式类正则

  • EMAIL: 邮箱
  • MOBILE_CN: 中国大陆手机号
  • TEL_CN: 中国大陆座机
  • ID_CARD_CN: 中国大陆身份证

net: 网络相关正则

  • URL: 通用 URL:协议可选
  • HTTP_URL: HTTP/HTTPS URL:必须带协议
  • IP_V4: IPv4:
  • DOMAIN: 域名

account: 账号相关正则

  • USERNAME: 用户名:4~16 位,以字母开头,允许数字和下划线
  • PASSWORD_SIMPLE: 简单密码:6~20 位任意字符
  • PASSWORD_STRONG: 强密码:8~20 位,至少一个大写、一个小写、一个数字、一个特殊字符

datetime: 日期时间类正则

  • DATE_YYYY_MM_DD: 日期:2026-05-13
  • TIME_HH_MM_SS: 时间:23:59:59
  • DATETIME_YYYY_MM_DD_HH_MM_SS: 日期时间:2026-05-13 23:59:59

file: 文件相关正则

  • FILE_EXT: 文件扩展名提取
  • IMAGE_EXT: 图片文件扩展名
  • VIDEO_EXT: 视频文件扩展名
  • AUDIO_EXT: 音频文件扩展名
  • ZIP_EXT: 压缩包文件扩展名

color: 颜色相关正则

  • HEX_COLOR: Hex 颜色:#RGB/#RGBA/#RRGGBB/#RRGGBBAA
  • RGB_COLOR: RGB/RGBA 颜色
  • HSL_COLOR: HSL/HSLA 颜色

browser: 浏览器/前端场景正则

  • HTML_TAG: HTML 标签
  • HTML_COMMENT: HTML 注释
  • BASE64_DATA_URL: Base64 Data URL
  • JSON_LIKE: JSON 字符串外形粗校验