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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jz-toolkit

v1.2.0

Published

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

Readme

jz-toolkit

🚀 一个轻量级、功能丰富的 JavaScript/TypeScript 工具库。

🆕 最近更新

v1.2.0
  • 新增 color 模块 - 颜色工具函数集合
  • 新增 generateColors() - 生成指定数量的随机十六进制颜色
  • 新增 generateRandomColor() - 生成单个随机十六进制颜色
  • 新增 generateHarmoniousColors() - 生成基于HSL的和谐色彩组合
  • 新增 generateGradientColors() - 生成渐变色彩组合
  • 新增 hexToRgb() - 将十六进制颜色转换为RGB格式
  • 新增 rgbToHex() - 将RGB颜色转换为十六进制格式
  • 新增 hslToHex() - 将HSL颜色转换为十六进制格式
  • 新增 hexToHsl() - 将十六进制颜色转换为HSL格式
  • 新增颜色验证函数:isValidHex(), isValidRgb(), isValidHsl()
import { generateColors, hexToRgb, generateHarmoniousColors } from "jz-toolkit";

// 生成8个随机颜色
const colors = generateColors(8);
// 返回: ['#FF5733', '#33FF57', '#5733FF', ...]

// 十六进制转RGB
const rgb = hexToRgb("#FF5733");
// 返回: { r: 255, g: 87, b: 51 }

// 生成和谐色彩组合
const harmoniousColors = generateHarmoniousColors(120, 6, 70, 50);
// 返回: ['#26D926', '#26D9D9', '#2626D9', ...]
v1.1.9
  • 新增 renderTemplate() - 字符串模板替换函数,支持灵活的变量替换
import { renderTemplate } from "jz-toolkit";

const result = renderTemplate(
  { name: "张三", money: 100.5 },
  "你好, {{name}}! 你的余额是 {{money}} 元。",
);
// 返回: "你好, 张三! 你的余额是 100.50 元。"
v1.1.8
  • 新增 toThousandsIntl() - 国际化数字千分位格式化函数,支持多地区格式
  • 新增 toThousands() - 常规数字千分位格式化函数
import { toThousandsIntl, toThousands } from "jz-toolkit";

toThousandsIntl(1234567.89, "zh-CN"); // '1,234,567.89'
toThousandsIntl(1234567.89, "de-DE"); // '1.234.567,89'
toThousands(1234567.89); // '1,234,567.89'

特点

类型安全 - 使用 TypeScript 编写,提供完整的类型定义

📦 模块化 - 支持按需导入,减少打包体积

高性能 - 精心优化的实现

🔧 易于扩展 - 清晰的项目结构,易于添加新功能

📚 良好文档 - 每个函数都有详细的文档和示例

安装

  npm i jz-toolkit

官方文档地址 - 更多Api在文档查阅

http://172.81.245.148:8098/api/utils.html

快速开始

聊天群

完整导入

import * as _ from "jz-toolkit";

_.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
_.capitalize("hello"); // 'Hello'

按需导入

import { chunk, capitalize } from "jz-toolkit";

chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
capitalize("hello"); // 'Hello'

模块导入

import * as array from "jz-toolkit/array";
import * as object from "jz-toolkit/object";
import * as string from "jz-toolkit/string";

array.chunk([1, 2, 3, 4], 2);
object.pick({ a: 1, b: 2 }, ["a"]);
string.capitalize("world");

开发

安装依赖

npm install

构建

npm run build

开发模式(监视文件变化)

npm run dev

运行测试

npm test

查看测试覆盖率

npm run test:coverage

代码格式化

npm run format

Linting

npm run lint

项目结构

src/
├── index.ts           # 主入口
├── types/             # 类型定义
├── array/             # 数组模块
├── object/            # 对象模块
├── string/            # 字符串模块
└── utility/           # 工具函数模块

许可证

MIT

贡献

欢迎贡献!请提交 PR 或 Issue。