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

@shihengtech/utils

v0.0.11

Published

A collection of utility tools for frontend projects

Readme

@shihengtech/utils

pipeline status coverage report

一个轻量级的 JavaScript/TypeScript 工具函数库。

✨ 特性

  • 🚀 轻量高效 - 精简的代码实现,最小化包体积
  • 📦 双格式支持 - 同时支持 ESM 和 CommonJS
  • 🔒 类型安全 - 使用 TypeScript 编写,提供完整的类型定义
  • 🌲 Tree Shaking - 支持按需引入,减少打包体积
  • 完善测试 - 高覆盖率的单元测试

📦 安装

# npm
npm install @shihengtech/utils

# pnpm
pnpm add @shihengtech/utils

# yarn
yarn add @shihengtech/utils

🔨 使用

fnRunner - 带重试的异步执行器

import { fnRunner } from '@shihengtech/utils'

// 执行异步函数,失败后最多重试 3 次
const result = await fnRunner(
  async () => fetch('/api/data').then(r => r.json()),
  3
)

createQueryWithCache - 带缓存的查询函数

import { createQueryWithCache } from '@shihengtech/utils'

const fetchUser = createQueryWithCache(
  'user',
  async (id: string) => fetch(`/api/users/${id}`).then(r => r.json()),
  { maxAge: 60000 } // 缓存 1 分钟
)

const user = await fetchUser('123')

ReplaySubject - 响应式数据流

import { ReplaySubject } from '@shihengtech/utils'

const subject = new ReplaySubject<number>(1)

subject.subscribe(value => console.log(value))
subject.next(1) // 输出: 1
subject.next(2) // 输出: 2

📖 文档

查看完整文档:文档站点

🛠️ 开发

# 安装依赖
pnpm install

# 开发模式(监听文件变化)
pnpm dev

# 构建
pnpm build

# 运行测试
pnpm test

# 运行测试(单次)
pnpm test:run

# 运行测试(覆盖率)
pnpm test:coverage

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

# 构建文档
pnpm docs:build

📊 测试覆盖率

| 模块 | 语句 | 分支 | 函数 | 行 | | -------------------- | ------ | ------ | ------ | ------ | | 总计 | 92.83% | 87.09% | 88.23% | 92.83% | | ReplaySubject | 100% | 100% | 100% | 100% | | createQueryWithCache | 96.38% | 88.88% | 100% | 96.38% | | fnRunner | 81.25% | 83.33% | 100% | 81.25% |

运行 pnpm test:coverage 查看详细覆盖率报告。

📁 项目结构

@shihengtech/utils/
├── src/
│   ├── index.ts              # 入口文件
│   ├── class/                # 类
│   │   └── ReplaySubject/    # 响应式数据流
│   └── utils/                # 工具函数
│       ├── fnRunner/         # 重试执行器
│       └── createQueryWithCache/  # 缓存查询
├── docs/                     # VitePress 文档
├── dist/                     # 构建输出
└── package.json

📄 License

MIT