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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@suey/printer

v1.1.9

Published

设置 npm 源

Downloads

12

Readme

设置 npm 源

npm config set registry https://registry.npmjs.org

安装

npm install @suey/printer --save

import { print, printInfo, printWarn, printError } from '@suey/printer';

`调用这个函数你可以格式化打印你想要的信息, 相比于 console.log, 此函数的调用更加符合函数化, 人性化
请注意, 由于控制台所处于的平台不同, 可能出现打印失效的情况
例如:CSS 样式, 可能在 Windows 控制台中可能就会出现不支持的情况
目前 ANSI 模式表现良好`

print('HelloWorld'); // 无格式化信息

print(toColor('red', 'HelloWorld'), '你的打印信息的位置可以自己选择'); // 使用toColor配合,红色字体信息

print(toColor('red'), 'HelloWrold'); // 使用toColor配合,红色字体信息

print(toColor(['white', 'red:bg']), 'HelloWorld'); // 使用toColor创建多ANSI格式的样式

print(toColor({ color: 'red' }), 'HelloWrold'); // 使用toColor创建css格式的样式, 用这个方式相较于直接书写css更加友好,具有ts类型提示

printInfo('HelloWrold!');

printWarn('Warn'); // 打印一条警告信息, 黄色字体

printError('error'); // 打印一条错误信息, 红色字体
import { Printer } from '@suey/printer';
// 通过 Printer 类获得你想要的日志打印格式

Printer.print('hello');

Printer.printInfo('hello');

Printer.printWarn('hello');

Printer.printError('hello');

// 在此中你可以设置打印的内容, 打印的格式
// init 会改变所有 Printer 静态方法上的打印格式. 如果你需要创建一个特殊额, 请使用 new 关键字为其生成一个对象
Printer.init({}, {});

type PrintOptions = Partial<{
  autoPrintName: boolean; // 是否自动打印 NAME
  printName: string; // NAME 值

  autoPrintTime: boolean; // 是否自动打印时间
  printTime: () => string; // 时间的获取函数

  autoPrintType: boolean; // 是否自动打印类型, 例如 INFO, WARN
  printType: string; // 打印类型, 其中固定方法不能被覆盖

  autoPrintThead: boolean; // 是否自动打印所在线程, 默认为 MAIN 主线程, 你可以自定义
  printThead: string; // 线程名字
}>;

type ColorInfo = Partial<{ // 对应上述类型, 要求返回一个格式化样式信息, 使用 toColor 函数创造样式信息
  printName: __SYMBLE_ARRAY__<[string, ...(unknown[])]>;
  printTIme: __SYMBLE_ARRAY__<[string, ...(unknown[])]>;
  printType: __SYMBLE_ARRAY__<[string, ...(unknown[])]>;
  printThead: __SYMBLE_ARRAY__<[string, ...(unknown[])]>;
}>;