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

@dao3fun/arena-rich

v1.0.5

Published

得到更好的控制台输出

Downloads

623

Readme

Arena-Rich

得到更好的控制台输出

Features

  • 清晰的层级显示,让输出更美观
  • 自动展开对象、数组
  • 自定义最大对象深度、字符串最大长度、占位符、省略字符等
  • 循环引用检测

Usage

引入 Rich 对象

import Rich from '@dao3fun/arena-rich'

使用Rich.print()输出各种内容

Rich.print("hello world");
Rich.print(993244853);
Rich.print({
  name: "surfish",
  age: null,
  gender: undefined,
  friends: [
    "Alray",
    "laiq"
  ],
  address: {
    country: "China"
  }
});
Rich.print(new Date());
Rich.print(1145141919810n);
Rich.print(Symbol("arena"));
Rich.print(world);

输出结果:

输出结果

Configs

Rich.enable: bool

选择是否启用 Rich 输出,默认为 true。

Rich.config

配置 Rich 输出的参数

config.maxDepth: number

输出对象的最大深度,默认为 5。

config.maxStringLength: number

输出字符串的最大长度,默认为 40。如果字符串超过这个长度,将会从中间位置截断,并添加省略号。

config.placeholder: string

如果对象嵌套深度超过了 config.maxDepth,将会显示这个占位符。默认为 (...)

config.tab: string

由于 Arena 编辑器中控制台会忽略所有空格,需要有一些字符代替空格展示缩进关系。默认为 ---|

Methods

Rich.print(...args: any[]): void

在控制台输出内容

Rich.objToString(obj: any, depth: number = 0): string

arena-rich 内部使用的方法,将任意对象转换为字符串