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

wgbx-tools

v0.0.4

Published

make your favorite tools

Readme

说明

不依赖任何第三方包,纯原生方法实现,使用 es 模块导出,可被 webpack,vite 等构建工具进行 tree-shaking,未使用的方法不会进入构建环节,请放心食用

约定

  • 使用本包请锁定版本,避免后续版本使用破坏性改动影响生产代码
  • 所有带 Async 的方法都为异步函数,不会在方法中特别说明

安装

npm install wgbx-tools
// or
pnpm add wgbx-tools

暴露方法

  • Browser

    • exitFullScreen:退出全屏模式
    • scrollToTop:滚动到页面顶部
    • isSupportWebP:检测当前浏览器是否支持 WebP 图片格式
    • exitFullScreen:进入全屏模式
  • Environment

    • userEnvironment:变量获取当前用户环境,包括浏览器类型、微信等移动设备环境等
  • Regex

    • isEmail:匹配电子邮件地址
    • isIdCard:匹配身份证号码
    • isTelNumber:匹配手机号
    • isUrl:匹配 URL 地址
  • String

    • firstUpperCase:将字符串的首字母大写
    • getCamelCase:将字符串转换为 camel case 格式
    • getKebabCase:将字符串转换为 kebab case 格式
    • randomString:生成指定长度的随机字符串
    • telEncrypt:对手机号进行加密处理
  • Time

    • formatPassTime:格式化时间间隔
    • isLeapYear:判断给定的年份是否为闰年
  • Function

    • parseJSONToObject:将 JSON 字符串解析为对象
    • mergeTargeObj:合并目标对象和源对象
  • Tools

    • addQuery:向给定的 URL 中添加查询参数
    • addVConsoleScript:添加 vconsole 脚本
    • compareVersion:比较两个版本号的大小
    • getFileExtension:获取文件名中的扩展名
    • getFileImageSizeAsync:获取图片文件尺寸
    • getImageSizeAsync:获取图片尺寸
    • getQuery:获取 URL 中的查询参数
    • mergeTargeObj:基于源对象与目标对象合并
    • loadScriptAsync:动态加载指定 URL 的 JavaScript 文件
    • preLoadImageAsync:从指定的 URL 加载图片
    • preLoadImagesAsync:从指定的 URL 加载图片数组
    • removeQuery:向给定的 URL 中移除查询参数
    • toAbsoluteUrl:将 URL 转换为绝对 URL

单元测试

针对方法生成单元测试

基于 TypeScript

  • 方法都附带详细类型以及注释(func/desc/returns/example...)