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

yangyonqian-console-enhance

v2.0.4

Published

A powerful console enhancement library with color support and chainable API

Readme

yangyonqian-console-enhance

一个强大的 console 增强库,支持颜色输出和链式调用 API,提供完整的 TypeScript 类型支持。

特性

  • 🎨 支持 8 种文字颜色和 8 种背景颜色
  • 🔗 支持链式调用,如 console.blue.bgRed('text')
  • 📘 完整的 TypeScript 类型提示
  • 🌐 支持 Node.js 和浏览器环境
  • 🚀 零配置,导入即用

安装

npm install yangyonqian-console-enhance

使用方法

基本使用

import "yangyonqian-console-enhance";

// 基本颜色
console.blue("这是蓝色文字");
console.red("这是红色文字");
console.green("这是绿色文字");

// 背景颜色(自动使用白色文字)
console.bgRed("这是红色背景,文字自动为白色");
console.bgBlue("这是蓝色背景,文字自动为白色");

// 链式调用(文字颜色 + 背景颜色)
console.blue.bgRed("这是红底蓝字");
console.red.bgYellow("这是黄底红字");
console.green.bgBlue("这是蓝底绿字");

支持的颜色

文字颜色

  • black - 黑色
  • red - 红色
  • green - 绿色
  • yellow - 黄色
  • blue - 蓝色
  • magenta - 洋红色
  • cyan - 青色
  • white - 白色

背景颜色

  • bgBlack - 黑色背景
  • bgRed - 红色背景
  • bgGreen - 绿色背景
  • bgYellow - 黄色背景
  • bgBlue - 蓝色背景
  • bgMagenta - 洋红色背景
  • bgCyan - 青色背景
  • bgWhite - 白色背景

使用其他 console 方法

console.blue.info("这是 info 方法 - 蓝色");
console.red.warn("这是 warn 方法 - 红色");
console.green.error("这是 error 方法 - 绿色");
console.yellow.debug("这是 debug 方法 - 黄色");

链式调用示例

// 单色文字
console.blue("蓝色文字");

// 单色背景
console.bgRed("红色背景");

// 文字颜色 + 背景颜色
console.blue.bgRed("红底蓝字");
console.red.bgYellow("黄底红字");

// 可以继续链式调用(后面的会覆盖前面的)
console.blue.bgRed.green("注意:最后设置的颜色会生效");

API

导入方式

// 方式 1: 直接导入(自动增强全局 console)
import "yangyonqian-console-enhance";

// 方式 2: 导入并获取增强的 console
import enhanceConsole from "yangyonqian-console-enhance";
const myConsole = enhanceConsole(console);

类型定义

所有颜色方法都支持完整的 TypeScript 类型提示,包括:

  • 文字颜色方法
  • 背景颜色方法
  • console 标准方法(log, info, warn, error, debug)

示例

import "yangyonqian-console-enhance";

// 基本使用
console.blue("Hello World");
console.red("Error message");
console.green("Success message");

// 链式调用
console.blue.bgRed("Important message");
console.yellow.bgBlue("Warning message");

// 使用其他方法
console.cyan.info("Info with cyan color");
console.magenta.error("Error with magenta color");

环境支持

  • ✅ Node.js (所有版本)
  • ✅ 浏览器 (现代浏览器)
  • ✅ TypeScript

特性说明

  • 自动白色文字:当只设置背景颜色时,文字颜色会自动设置为白色,确保在深色背景上的可读性
  • 自定义文字颜色:如果同时设置了文字颜色和背景颜色,将使用指定的文字颜色

注意事项

  1. 颜色效果在支持 ANSI 转义序列的终端中才能正常显示
  2. 在 Windows 的旧版 CMD 中可能无法正常显示颜色
  3. 建议在支持颜色的终端中使用(如 VS Code 终端、iTerm2、Windows Terminal 等)
  4. 当只使用背景颜色时,文字会自动变为白色以确保可读性

开发

# 安装依赖
npm install

# 编译
npm run build

# 测试
npm test

发布

# 构建项目
npm run build

# 发布到 npm
npm publish

License

MIT