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

@kabeep/palette

v1.1.0

Published

A Node.js library for terminal text colour & style in FP.

Downloads

17

Readme

🎨 一个 FP 范式的 Node.js 库用来设置终端文本的颜色和样式。

NodeJS License NPM Codecov BundlePhobia CircleCI

English | 简体中文

📖 简介

chalk 有友好的链式 API,但也是我认为它不足的地方,尽管 sindresorhus 的杰出工作尽可能缩小了包体积, 但我不认为核心问题在于 为什么不换成更小的着色包?

  • 不能树摇,不能以 FP 范式例如 pipe/compose 来编码。
  • 如果只需要着色红色失败和绿色成功信息,仍需要通过工厂函数创建完整的 chalk
  • 在轻量场景中远不如静态 ANSI 字符串的性价比。

所以我创建了这个包,它和 chalk 一样支持 ANSI 16 色256 色16 百万真彩色

比起其他轻量包,除了基础的 ANSI 关键字,它还支持 十六进制数字表示法 (Hex) / 三原色光模式 (RGB) / CSS 关键字

但这不意味着它牺牲了 体积性能,相反它在 基准测试报告 中表现优异。 当然所有的着色包都已经足够快了,但如果你重视尺寸和性能, @kabeep/palette 是一个不错的选择。

查看 文档

📦 安装

npm install @kabeep/palette --save
yarn add @kabeep/palette
pnpm add @kabeep/palette

⚙️ 使用

CommonJS

const pipe = require('lodash.flow');
const { bgRgb, hex, keyword, yellowBright } = require('@kabeep/palette');

const padding = (text: string) => ` ${text} `;
const palette = pipe(keyword('gold'), padding, bgRgb(255, 0, 0));

console.log(palette('Error'), yellowBright('Warning'), hex('#ff0000')('Message'));

ESModule

import pipe from 'lodash.flow';
import { bgRgb, hex, keyword, yellowBright } from '@kabeep/palette';

const padding = (text: string) => ` ${text} `;
const palette = pipe(keyword('gold'), padding, bgRgb(255, 0, 0));

console.log(palette('Error'), yellowBright('Warning'), hex('#ff0000')('Message'));

🌈 样式

修饰符

  • reset - 重置当前样式。
  • bold - 粗体文本。
  • dim - 降低文本不透明度。
  • italic - 将文本设置为斜体 (未得到广泛支持)。
  • underline - 文本下划线 (未得到广泛支持)。
  • overline - 文本上划线 (未得到广泛支持)。
  • inverse- 反转背景和前景色。
  • hidden - 打印文本但使其不可见。
  • strikethrough - 文本删除线 (未得到广泛支持)。

前景色

  • black - 黑色文本
  • red - 红色文本
  • green - 绿色文本
  • yellow - 黄色文本
  • blue - 蓝色文本
  • magenta - 品红色文本
  • cyan - 青色文本
  • white - 白色文本
  • gray - 灰色文本
  • redBright - 亮红色文本
  • greenBright - 亮绿色文本
  • yellowBright - 亮黄色文本
  • blueBright - 亮蓝色文本
  • magentaBright - 亮品红色文本
  • cyanBright - 亮青色文本
  • whiteBright - 亮白色文本

背景色

  • bgBlack - 黑色背景
  • bgRed - 红色背景
  • bgGreen - 绿色背景
  • bgYellow - 黄色背景
  • bgBlue - 蓝色背景
  • bgMagenta - 品红色背景
  • bgCyan - 青色背景
  • bgWhite - 白色背景
  • bgGray - 灰色背景
  • bgRedBright - 亮红色背景
  • bgGreenBright - 亮绿色背景
  • bgYellowBright - 亮黄色背景
  • bgBlueBright - 亮蓝色背景
  • bgMagentaBright - 亮品红色背景
  • bgCyanBright - 亮青色背景
  • bgWhiteBright - 亮白色背景

十六进制数字表示法 (Hex)

  • hex - (三位) #fff, ...
  • hex - (六位) #ffffff, ...
  • hex - (无#号) fff, ffffff, ...

三原色光模式 (RGB)

  • rgb - (255, 255, 255), ...

CSS 关键字

W3C Wiki 查看完整列表。

  • keyword - azure, gold, indigo, ...

💐 致谢

🔗 关联库

  • palette-cli - 一个 Node.js 库使你的终端输入变得丰富多彩。

🤝 贡献

欢迎通过 Pull Requests 或 Issues 来贡献你的想法和代码。

📄 许可

本项目采用 MIT 许可证。详情请见 LICENSE 文件。