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

gsyh-utils

v1.0.9

Published

gsyh utils package

Downloads

216

Readme

gsyh-utils

项目简介

购商云汇(gsyh)工具库,提供常用的JavaScript/TypeScript工具函数,包括防抖节流、深拷贝、时间处理、正则表达式验证、URL处理等实用功能,助力前端开发效率提升。

安装

# npm 安装
npm install gsyh-utils

# yarn 安装
yarn add gsyh-utils

# pnpm 安装
pnpm add gsyh-utils

功能模块

1. 通用工具 (common)

  • debounce - 函数防抖,限制高频触发事件的执行频率
  • throttle - 函数节流,间隔指定时间执行一次函数
  • deepCopy - 深度拷贝对象/数组数据

2. 时间处理 (time)

  • formatDateTime - 格式化时间为指定格式
  • 其他时间相关工具函数

3. 正则表达式 (regx)

  • idCardNoReg - 身份证号验证正则
  • mobileReg - 手机号验证正则
  • moneyReg - 金额验证正则(最多两位小数)
  • urlReg - URL地址验证正则
  • emailReg - 邮箱验证正则

4. 其他工具模块

  • file - 文件处理相关工具
  • href - URL处理相关工具
  • http - HTTP请求相关工具

使用示例

防抖函数

import { debounce } from 'gsyh-utils';

// 创建防抖处理的搜索函数
const debouncedSearch = debounce((query) => {
    console.log('搜索:', query);
    // 执行搜索逻辑
}, 500);

// 在输入事件中使用
inputElement.addEventListener('input', (e) => {
    debouncedSearch(e.target.value);
});

时间格式化

import { formatDateTime } from 'gsyh-utils';

// 格式化当前时间
const now = new Date();
const formattedDate = formatDateTime(now, 'yyyy-MM-dd hh:mm:ss');
console.log(formattedDate); // 例如: 2023-10-15 14:30:25

// 格式化时间戳
const timestamp = 1634253600000;
const dateStr = formatDateTime(timestamp, 'yyyy/MM/dd');
console.log(dateStr); // 例如: 2021/10/15

正则验证

import { mobileReg, emailReg } from 'gsyh-utils';

// 验证手机号
const isValidMobile = mobileReg.test('13812345678');
console.log(isValidMobile); // true

// 验证邮箱
const isValidEmail = emailReg.test('[email protected]');
console.log(isValidEmail); // true

许可证

本项目采用 ISC 许可证 - 查看 LICENSE 文件了解详情