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

@zenstone/ts-utils

v0.2.0

Published

A collection of utility functions for TypeScript

Readme

@zenstone/ts-utils

version dt

从实际项目中沉淀的 TypeScript 工具库。不追求大而全,只收录真正在生产中反复使用的函数。

核心设计原则:

  • 类型推断优先 — 泛型从原函数推断,不需要手动指定。retry(fn) 返回的函数自动保持 fn 的参数和返回值类型。
  • 高阶函数模式retrytimeout 等都是 fn => fn 的包装器,返回增强后的函数而非立即执行。
  • unknown 守住边界 — 对外暴露的类型一律 unknown,迫使使用者显式收窄;any 只出现在泛型约束的基底声明中。
  • 不过度抽象 — 没有 DI、没有装饰器、没有配置体系。三行能解决的事不封装成类。

使用 Bun.js 开发,兼容 Node.js 运行时。

API 文档见 GitHub Wiki(由 TypeDoc + typedoc-github-wiki-theme 生成)。

安装

# node
npm install @zenstone/ts-utils
# bun
bun add @zenstone/ts-utils

使用

整体导入

import { retry, isStr, errMsg } from '@zenstone/ts-utils';

独立导入(推荐)

ESM 支持子路径导入:

import { retry, RetryExhaustedError, TimeoutError } from '@zenstone/ts-utils/async';
import { isStr, errMsg, isNumber, isInferObj } from '@zenstone/ts-utils/guards';
import { createPathUtils } from '@zenstone/ts-utils/path';

模块列表

| 模块 | 说明 | 导入路径 | |------|------|----------| | async | 异步工具函数 | @zenstone/ts-utils/async | | guards | Type Guards 和基础类型工具 | @zenstone/ts-utils/guards | | path | 路径处理 | @zenstone/ts-utils/path | | http | HTTP 相关工具 | @zenstone/ts-utils/http | | remote | 远程模块加载 | @zenstone/ts-utils/remote | | fetch-download | 下载工具 | @zenstone/ts-utils/fetch-download | | misc | 杂项工具(timer、singleton、configurable 等) | @zenstone/ts-utils/misc | | events | 事件发布订阅 | @zenstone/ts-utils/events | | traits | traits | @zenstone/ts-utils/traits |

模块详情

async

异步工具函数

Classes:

Functions:

guards

Type Guards 和基础类型工具

Functions:

path

路径处理

Functions:

http

HTTP 相关工具

Functions:

remote

远程模块加载

Classes:

Functions:

fetch-download

下载工具

Classes:

Functions:

misc

杂项工具(timer、singleton、configurable 等)

Functions:

events

事件发布订阅

Functions:

traits

traits

Functions: