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

@jiayouzuo/uniapp-shared-js

v1.5.2

Published

uni-app 通用工具函数库

Readme

@jiayouzuo/uniapp-shared-js

uni-app 通用工具函数库

安装

npm install @jiayouzuo/uniapp-shared-js

API 速查表

📡 request.ts - 网络请求

| 导出项 | 类型 | 作用 | |--------|------|------| | createRequest | 函数 | 创建请求实例,支持自动重试、401重登录、文件上传 | | ApiResponse | 类型 | 响应数据结构 | | RequestOptions | 类型 | 请求配置 | | UploadOptions | 类型 | 上传配置 | | RequestConfig | 类型 | 请求实例配置 |

💾 storage.ts - 本地存储

| 导出项 | 类型 | 作用 | |--------|------|------| | setStorage | 函数 | 设置存储,支持过期时间 | | getStorage | 函数 | 获取存储,自动处理过期 | | removeStorage | 函数 | 移除存储 | | clearStorage | 函数 | 清空存储 | | StorageOptions | 类型 | 存储配置 |

⏱️ timer.ts - 定时器工具

| 导出项 | 类型 | 作用 | |--------|------|------| | createTimer | 函数 | 创建定时器,支持立即执行、次数限制 | | createCountdown | 函数 | 创建倒计时定时器 | | delay | 函数 | 延时执行(Promise版本) | | debounce | 函数 | 防抖函数 | | throttle | 函数 | 节流函数 | | TimerOptions | 类型 | 定时器配置 | | TimerInstance | 类型 | 定时器实例 |

🔒 safe.ts - 安全工具

| 导出项 | 类型 | 作用 | |--------|------|------| | jsonParse | 函数 | 安全的JSON解析,失败返回默认值 | | jsonStringify | 函数 | 安全的JSON序列化,失败返回默认值 | | toNumber | 函数 | 安全的数字转换,失败返回默认值 | | arrayAt | 函数 | 安全的数组访问,越界返回默认值 |

🔐 crypto.ts - 加密工具

| 导出项 | 类型 | 作用 | |--------|------|------| | aesCBCDecrypt | 函数 | AES-CBC解密 | | aesCBCEncrypt | 函数 | AES-CBC加密 | | base64Encode | 函数 | Base64编码 | | base64Decode | 函数 | Base64解码 | | simpleHash | 函数 | 简单哈希(非安全场景) |

🆔 uid.ts - UUID生成

| 导出项 | 类型 | 作用 | |--------|------|------| | uuid | 函数 | 生成UUID v4 | | shortId | 函数 | 生成短ID(8位) | | timestampId | 函数 | 生成时间戳ID |

🔌 socket.ts - WebSocket管理

| 导出项 | 类型 | 作用 | |--------|------|------| | createWebSocketManager | 函数 | 创建WebSocket管理器,支持心跳、自动重连、消息分发 | | WebSocketOptions | 类型 | WebSocket配置 | | WebSocketMessage | 类型 | WebSocket消息结构 | | WebSocketManager | 类型 | WebSocket管理器实例 |

📁 fileSystem.ts - 文件系统

| 导出项 | 类型 | 作用 | |--------|------|------| | getUserDir | 函数 | 获取用户文件根目录 | | resolvePath | 函数 | 拼接完整文件路径 | | writeFile | 函数 | 写入文件 | | readFile | 函数 | 读取文件 | | appendFile | 函数 | 追加内容到文件末尾 | | removeFile | 函数 | 删除文件 | | copyFile | 函数 | 复制文件 | | renameFile | 函数 | 重命名/移动文件 | | mkdir | 函数 | 创建目录(支持递归) | | rmdir | 函数 | 删除目录 | | readDir | 函数 | 读取目录内容 | | readDirWithStats | 函数 | 读取目录详细内容(含文件信息) | | getFileStats | 函数 | 获取文件/目录信息 | | exists | 函数 | 检查文件/目录是否存在 | | getFileSize | 函数 | 获取文件大小 | | saveTempFile | 函数 | 保存临时文件到用户目录 | | readJSON | 函数 | 读取JSON文件 | | writeJSON | 函数 | 写入JSON文件 | | clearDir | 函数 | 清空指定目录下的所有文件 |

📅 date.ts - 时间格式化

| 导出项 | 类型 | 作用 | |--------|------|------| | formatDate | 函数 | 格式化时间,返回多种格式(formatted、dateStr、timeStr、relative等) | | DateResult | 类型 | 时间格式化结果 |

📝 format.ts - 数字格式化

| 导出项 | 类型 | 作用 | |--------|------|------| | formatThousand | 函数 | 千分位格式化 | | formatNumber | 函数 | 数字简化显示(1.2万、1.2亿) | | formatFileSize | 函数 | 格式化文件大小(KB、MB、GB) | | formatPercent | 函数 | 格式化百分比 | | FormatNumberOptions | 类型 | 数字简化配置 |

License

MIT