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

@clare-hjh/utils

v1.2.0

Published

一个实用的 JavaScript/TypeScript 工具函数库,提供常用的类型判断、文件操作、DOM操作、表单验证等功能。

Readme

@clare-hjh/utils

一个实用的 JavaScript/TypeScript 工具函数库,提供常用的类型判断、文件操作、DOM操作、表单验证等功能。

📦 安装

npm install @clare-hjh/utils

或者使用 yarn:

yarn add @clare-hjh/utils

或者使用 pnpm:

pnpm add @clare-hjh/utils

🚀 使用

ES6 模块导入

import { isString, debounce, throttle, checkPhoneNumber } from '@clare-hjh/utils';

CommonJS 导入

const { isString, debounce, throttle, checkPhoneNumber } = require('@clare-hjh/utils');

📚 功能模块

类型判断 (is)

  • is() - 通用类型判断
  • isString() - 判断是否为字符串
  • isNumber() - 判断是否为数字
  • isBoolean() - 判断是否为布尔值
  • isArray() - 判断是否为数组
  • isObject() - 判断是否为对象
  • isFunction() - 判断是否为函数
  • isDate() - 判断是否为日期
  • isPromise() - 判断是否为Promise
  • isAsyncFunction() - 判断是否为异步函数
  • isElement() - 判断是否为DOM元素
  • isClient() - 判断是否为客户端环境
  • isWindow() - 判断是否为Window对象
  • isHexColor() - 判断是否为16进制颜色
  • isDef() / isUnDef() - 判断是否已定义/未定义
  • isNull() / isNullOrUnDef() - 判断是否为null或undefined

文件操作 (file)

  • isImageFile() - 判断是否为图片文件
  • isDocumentFile() - 判断是否为文档文件
  • getFileExtension() - 获取文件扩展名
  • getFileNameWithoutExtension() - 获取不带扩展名的文件名
  • getAssetUrl() - 生成Vite项目中静态资源的路径

DOM操作 (dom)

  • getElementPosition() - 获取元素相对于文档的坐标
  • scrollToTop() - 平滑滚动到页面顶部

下载功能 (download)

  • DownloadFile() - 文件下载功能

性能优化

  • debounce() - 防抖函数
  • throttle() - 节流函数

表单验证 (eleValidate)

  • checkPhoneNumber() - 手机号验证(必填)
  • validateSimplePhone() - 手机号验证(非必填)
  • validateSimpleIdCard() - 身份证号验证(非必填)
  • validatePassword() - 密码验证
  • passwordReg - 密码正则表达式

其他工具

  • checkForUpdate() - 检查应用更新
  • errorHandler - 全局错误处理

📖 详细文档

查看完整的API文档:文档地址

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License