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

@sop-cli/utils

v0.4.0

Published

> 前端通用工具函数库,基于 TypeScript 6.0+ 编写,支持 ESM / CJS / 浏览器 IIFE 全格式,无外部业务依赖,可在 Vue / React / 原生项目通用。

Readme

@sop-cli/utils

前端通用工具函数库,基于 TypeScript 6.0+ 编写,支持 ESM / CJS / 浏览器 IIFE 全格式,无外部业务依赖,可在 Vue / React / 原生项目通用。

特性

  • ✅ 纯 TypeScript 编写,完整类型提示
  • ✅ 支持 ESM / CommonJS / IIFE(CDN) 多格式产物
  • ✅ 天然 Tree-Shaking 按需引入
  • ✅ 零外部依赖,轻量无负担
  • ✅ 严格遵循 ESLint 编码规范
  • ✅ Monorepo 架构,可配合 @sop-cli/request 等包协同使用

安装

# npm
npm install @sop-cli/utils

# pnpm
pnpm add @sop-cli/utils

# yarn
yarn add @sop-cli/utils

https://www.npmjs.com/package/@sop-cli/utils

使用方式

ESM 导入(推荐)

import { cleanQueryParams, deepClone, omit, uniqBy } from '@sop-cli/utils';

CommonJS

const { cleanQueryParams } = require('@sop-cli/utils');

CDN 全局引入 IIFE

<script src="https://unpkg.com/@sop-cli/utils/dist/index.iife.js"></script>
<script>
  const { cleanQueryParams } = SopUtils;
</script>

常用工具列表

对象 / 数组工具

  • deepClone 深拷贝(规避 V8 delete 性能降级)
  • omit 剔除对象指定字段
  • pick 挑选对象指定字段
  • uniqBy 数组根据字段去重
  • arrayToTree 扁平数组转树形结构
  • treeToArray 树形结构转扁平数组

URL / 参数处理

  • cleanQueryParams 清理空值、undefined、null 后序列化参数
  • parseQuery 解析 url query 为对象
  • getUrlParam 获取单个 url 参数

类型判断

  • isPlainObject 是否纯对象
  • isArray / isString / isNumber / isBoolean
  • isNil / isEmpty 空值判断

格式化工具

  • formatDate 时间格式化
  • formatMoney 金额千分位格式化
  • formatPercent 百分比格式化

其他通用

  • sleep 延时等待
  • uuid 生成简易唯一标识
  • storage 本地存储封装(localStorage/sessionStorage)

项目架构

packages/utils/
├── src/            # 源码目录
├── dist/           # 构建产物 ESM / CJS / IIFE / d.ts
├── tsconfig.json   # TypeScript 配置
├── rolldown.config.ts # 打包配置
└── package.json

配套生态

  • @sop-cli/request 基于 Axios 企业级请求封装(解耦 UI、支持多框架)

License

MIT