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

my-tool-function-ts

v1.0.26

Published

一个功能丰富的 TypeScript 工具函数库,提供各种常用的工具函数来简化日常开发工作。

Readme

my-tool-function-ts

一个功能丰富的 TypeScript 工具函数库,提供各种常用的工具函数来简化日常开发工作。

项目概述

本项目是一个 TypeScript 工具函数库,包含以下功能模块:

  • 数组工具 (array): 数组操作相关的工具函数
  • 通用类型判断 (common): 通用的类型检测和判断函数
  • 函数工具 (function): 函数操作相关的工具函数
  • 本地存储 (localStorage): 浏览器本地存储操作工具
  • 数学工具 (math): 数学计算相关的工具函数
  • 数字处理 (number): 数字格式化和处理工具
  • 对象处理 (object): 对象操作相关的工具函数
  • 正则验证 (regular): 常用的正则表达式验证工具
  • 时间处理 (time): 时间和日期处理工具

项目架构

my-tool-function-ts/
├── src/                    # 源代码目录
│   ├── array/             # 数组工具模块
│   ├── common/            # 通用工具模块
│   ├── function/          # 函数工具模块
│   ├── localStorage/      # 本地存储模块
│   ├── math/              # 数学工具模块
│   ├── number/            # 数字处理模块
│   ├── object/            # 对象处理模块
│   ├── regular/           # 正则验证模块
│   ├── time/              # 时间处理模块
│   └── index.ts           # 主入口文件
├── docs/                  # VitePress 文档目录
│   ├── .vitepress/        # VitePress 配置
│   │   ├── theme/         # 自定义主题
│   │   │   ├── custom.css           # 主要样式文件
│   │   │   ├── critical.css         # 关键路径 CSS
│   │   │   ├── font-optimization.css # 字体优化
│   │   │   ├── performance-optimizer.js # 性能优化
│   │   │   ├── STYLE_GUIDE.md       # 样式指南
│   │   │   ├── DESIGN_TOKENS.md     # 设计令牌文档
│   │   │   └── MAINTENANCE_GUIDE.md # 维护指南
│   │   └── config.mts     # VitePress 配置
│   └── [modules]/         # 各模块文档
├── tests/                 # 测试目录
│   ├── css/              # CSS 测试
│   ├── visual/           # 视觉回归测试
│   ├── accessibility/    # 无障碍性测试
│   └── performance/      # 性能测试
├── scripts/               # 构建脚本
├── package.json           # 项目配置
├── tsconfig.json          # TypeScript 配置
└── rollup.config.js       # 打包配置

安装和使用

安装依赖

npm install
# 或
yarn install

开发模式

# 启动文档开发服务器
npm run docs:dev

# 构建项目
npm run build

# 运行测试
npm test

文档预览

# 启动文档开发服务器
npm run docs:dev

# 构建文档
npm run docs:build

# 预览构建的文档
npm run docs:preview

样式开发

# 运行样式测试
npm run test:styles

# CSS 优化
npm run optimize:css

# 检查未使用的 CSS
npm run analyze:unused-css

# 性能测试
npm run test:performance

功能模块说明

数组工具 (array)

提供数组操作相关的工具函数,如去重、排序、分组等。

通用类型判断 (common)

提供通用的类型检测函数,如判断数据类型、空值检测等。

函数工具 (function)

提供函数操作相关的工具,如防抖、节流、函数组合等。

本地存储 (localStorage)

提供浏览器本地存储的封装,支持过期时间、加密等功能。

数学工具 (math)

提供数学计算相关的工具函数,如精确计算、随机数生成等。

数字处理 (number)

提供数字格式化和处理工具,如千分位分隔、数字转换等。

对象处理 (object)

提供对象操作相关的工具函数,如深拷贝、对象合并、属性提取等。

正则验证 (regular)

提供常用的正则表达式验证工具,如邮箱、手机号、身份证等验证。

时间处理 (time)

提供时间和日期处理工具,如格式化、计算、转换等。

开发指南

添加新功能

  1. 在对应的模块目录下添加新的函数
  2. 更新模块的 index.ts 文件导出新函数
  3. docs 目录下添加相应的文档
  4. 运行测试确保功能正常

代码规范

  • 使用 TypeScript 编写代码
  • 遵循 ESLint 规范
  • 为每个函数添加完整的 JSDoc 注释
  • 编写单元测试

文档编写

  • 使用 VitePress 编写文档
  • 为每个函数提供详细的使用示例
  • 包含参数说明和返回值说明

样式开发规范

  • 设计令牌: 使用 CSS 自定义属性,避免硬编码值
  • 响应式设计: 采用移动设备优先的设计方法
  • 深色模式: 确保所有组件支持深色模式
  • 无障碍性: 遵循 WCAG 2.1 AA 标准
  • 性能优化: 保持 CSS 文件精简,优化加载速度
  • BEM 命名: 使用 BEM 命名约定保持代码一致性

详细的样式开发指南请参考:

构建和发布

构建

npm run build

发布

npm run prepublish  # 预发布检查
npm publish         # 发布到 npm
npm run postpublish # 发布后处理

贡献指南

我们欢迎各种形式的贡献!请阅读我们的 贡献指南 了解详细信息。

快速开始

  1. Fork 本仓库
  2. 创建功能分支
    git checkout -b feature/your-feature-name
  3. 提交更改
    git commit -m "feat: add your feature"
  4. 推送到分支
    git push origin feature/your-feature-name
  5. 创建 Pull Request

贡献类型

  • 🐛 Bug 修复:修复现有功能的问题
  • 新功能:添加新的工具函数或功能
  • 📚 文档改进:完善 API 文档和使用指南
  • 🎨 样式优化:改进 UI/UX 和响应式设计
  • 性能优化:提升代码执行效率和加载速度
  • 🧪 测试增强:添加或改进测试覆盖率

详细的开发规范和样式指南请参考 贡献指南

许可证

本项目采用 MIT 许可证。

📝 更新日志

v1.0.28 (2024-12-19)

  • 🗑️ 移除模块网格:删除首页的核心模块展示区域
    • 简化页面结构,专注于快速体验部分
    • 保留完整的功能文档链接和使用示例
    • 优化页面加载性能和用户体验

v1.0.27 (2024-12-19)

  • 🎨 重构模块网格设计:全面升级首页模块展示界面
    • 现代化卡片设计:多层阴影效果、渐变边框、3D悬停变换
    • 增强视觉层次:优化标题、图标、代码块和按钮样式
    • 流畅动画系统:自然缓动效果和微交互体验
    • 响应式优化:完美适配移动端和触摸交互
  • 🔧 重构HTML结构:将Markdown格式转换为HTML结构以支持高级样式
  • 🎯 现代化按钮设计:渐变背景、悬停效果和视觉反馈
  • 🌈 增强色彩系统:丰富的渐变色彩和视觉效果

v1.0.23

  • 修复 VitePress 主题配置问题
  • 完善项目文档结构
  • 优化构建配置

如有问题或建议,请提交 Issue 或 Pull Request。