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

@sunsetz/zutils

v1.0.1

Published

A lightweight, tree-shaking friendly frontend utility library

Readme

@sunsetz/zutils

一个 轻量、模块化、TypeScript 优先、Tree-shaking 友好 的前端高频工具库。

🎯 设计目标:

  • 覆盖 90% 前端项目的高频工具需求
  • 每个方法都「小而美、可维护」
  • 不重复造成熟库(如 lodash / dayjs)的重轮子

✨ 特性

  • ✅ TypeScript 优先,完整类型推导
  • ✅ Tree-shaking 友好(sideEffects: false
  • ✅ 模块化设计,支持按需引入
  • ✅ 零运行时依赖
  • ✅ 单元测试覆盖核心逻辑

📦 安装

npm install @sunsetz/zutils
# or
pnpm add @sunsetz/zutils
# or
yarn add @sunsetz/zutils

🚀 使用方式

1️⃣ 整包引入(推荐)

import { unique, deepClone } from '@sunsetz/zutils'

2️⃣ 模块引入

import { unique } from '@sunsetz/zutils/array'

3️⃣ 单方法引入(极致 Tree-shaking)

import unique from '@sunsetz/zutils/array/unique'

🧩 模块一览

Array

unique(arr)
chunk(arr, size)
flatten(arr, depth?)
compact(arr)
groupBy(arr, key)
intersection(a, b)

示例

unique([1, 1, 2]) // [1, 2]
chunk([1, 2, 3, 4], 2) // [[1,2],[3,4]]

Object

deepClone(obj)
deepMerge(target, source)
get(obj, path, defaultValue?)
set(obj, path, value)
pick(obj, keys)
omit(obj, keys)

示例

get({ a: { b: 1 } }, 'a.b') // 1

Function

debounce(fn, delay)
throttle(fn, delay)
once(fn)
memoize(fn)

示例

const onResize = debounce(() => {}, 300)

Async

sleep(ms)
retry(fn, times, delay?)

示例

await sleep(1000)

Storage

setStorage(key, value, expire?)
getStorage(key)
removeStorage(key)
clearStorage()

示例

setStorage('token', 'xxx', 1000 * 60)

Type

isString
isNumber
isBoolean
isFunction
isArray
isPlainObject

🧪 测试

pnpm test

使用 Vitest + jsdom,覆盖核心模块。


🗺 版本规划

  • v1.0:高频通用工具(当前)
  • v1.1:类型增强 + 边界优化
  • v2.0:业务级工具 / hooks

🤝 贡献

欢迎提 PR / Issue,一起把它打磨成真正好用的前端基础库。