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

zhiaiwan-utils

v1.0.3

Published

现代前端与 Node.js 通用工具函数库

Readme

zhiaiwan-utils

现代前端与 Node.js 通用工具函数库。支持 UMD / AMD / CMD / CommonJS / ESM,完整 TypeScript 类型,以及子路径按需引入。

安装

npm install zhiaiwan-utils
# 或
pnpm add zhiaiwan-utils

使用

子路径按需引入(推荐)

import { forEach } from 'zhiaiwan-utils/array';
import { get } from 'zhiaiwan-utils/object';

const collected: number[] = [];
forEach([1, 2, 3, 4], (n) => collected.push(n));
// collected => [1, 2, 3, 4]

整包引入

import { forEach, get, version } from 'zhiaiwan-utils';

Node.js(CommonJS)

const { forEach } = require('zhiaiwan-utils');
const { forEachRight } = require('zhiaiwan-utils/array');

浏览器(UMD 全局变量)

<script src="https://unpkg.com/zhiaiwan-utils/dist/umd/zhiaiwan-utils.min.js"></script>
<script>
  zhiaiwanUtils.forEach([1, 2, 3, 4], (n) => console.log(n));
  zhiaiwanUtils.version;
</script>

模块清单

| 模块 | 引入路径 | 函数 | |------|----------|------| | array | zhiaiwan-utils/array | forEach、forEachRight、each、find、findLast、findIndex、findLastIndex、filter、map、some、every、includes、concat、compact、chunk、union、intersection、difference、differenceBy、without、groupBy、keyBy、partition、uniq、uniqBy、sortBy、orderBy、maxBy、minBy、sum、sumBy、meanBy、min、max、mean、reduce、reduceRight、flatten、flattenDeep、head、last、take、drop | | object | zhiaiwan-utils/object | clone、cloneDeep、cloneWith、cloneDeepWith、get、set、has、findKey、findLastKey、pick、pickBy、omit、omitBy、merge、mergeWith、unset、defaults、defaultsDeep、assign、keys、values、mapKeys、mapValues、invert、fromPairs、forOwn、forIn、update、updateWith | | convert | zhiaiwan-utils/convert | toArray、toFinite、toInteger、toLength、toNumber、toSafeInteger、toString、toPath、toPlainObject、toPairs、toPairsIn、toLower、toUpper | | tree | zhiaiwan-utils/tree | traverseTree、traverseTreeBfs、forEachTree、findTreeNode、filterTreeNodes、getParentNodes、toTree、toFlatList、getTreeDepth、mapTree、pruneTree | | string | zhiaiwan-utils/string | trim、trimStart、trimEnd、startsWith、endsWith、pad、padStart、padEnd、escape、unescape、repeat、camelCase、kebabCase、snakeCase、capitalize、lowerCase、upperFirst | | util | zhiaiwan-utils/util | noop、identity、delay、defer、now、uniqueId、sleep、validateFields、defaultTo、size、range、times、constant、negate、iteratee、property、matches、matchesProperty、clamp、inRange、random | | verify | zhiaiwan-utils/verify | isString、isNumber、isBoolean、isArray、isArguments、isArrayBuffer、isTypedArray、isBuffer、isFunction、isNative、isObject、isPlainObject、isUndefined、isNull、isNil、isDate、isRegExp、isSymbol、isInteger、isSafeInteger、isLength、isEmpty、isMap、isSet、isWeakMap、isWeakSet、isError、isEqual、isEqualWith、isNaN、isFinite、isMatch、isMatchWith、isArrayLike、isObjectLike、isElement | | function | zhiaiwan-utils/function | once、debounce、throttle、before、after、memoize、partial、partialRight、flow、flowRight、curry | | color | zhiaiwan-utils/color | rgbToHex、hexToRgb、rgbStringToHex、getCssVariable、getThemePalette |

此外主入口导出 version(当前库版本号)。

发布产物

| 目录 | 格式 | 说明 | |------|------|------| | dist/cjs/ | CommonJS | 保留目录树,支持子路径 require | | dist/esm/ | ESM | 支持 Tree Shaking | | dist/types/ | TypeScript 声明 | 与 package.json 的 exports 字段映射 | | dist/umd/ | UMD 单文件 | .js / .min.js,全局名 zhiaiwanUtils |

开发脚本

pnpm test           # Jest 单元测试
pnpm test:coverage  # 覆盖率(阈值 80%)
pnpm bench          # 性能基准测试
pnpm lint           # ESLint

目录约定

  • 一函数一文件:每个工具函数独占 .ts 文件,默认导出
  • 模块聚合:每个子目录 index.ts 统一 re-export
  • 内部共享:src/_internal/ 存放库内共享逻辑,不对外 export
  • 版本号:src/version.ts 由构建流程自动生成,勿手改

License

MIT