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

console-class-browser

v1.0.30

Published

This module implements the Node.js `console` module for browser environments.

Readme

console-class-browser

简体中文
This module implements the Node.js console module for browser environments.
The motivation came from my attempt to simulate a shell in the frontend, where I found that console-browserify did not implement the Console class.
I originally considered submitting a PR, but the changes required would likely be extensive and might be rejected. Therefore, I spent a few hours rewriting this module.

Usage

The usage of this module is mostly the same as the Node.js standard library, with some minor differences.
A simple example (test.js):

const console = require("console-class-browser")

console.group("SIMPLE LOG")
  console.group("LOG")
    console.log("Hello %s", "World")
    console.info("Hello %s", "World")
    console.debug("Hello %s", "World")
    console.dirxml("Hello %s", "World")
    console.table("Hello %s", "World") // TODO
    console.warn("Hello %s", "World")
    console.groupEnd()
  console.group("ERROR")
    console.error("Bye %s", "Bug")
    console.trace("Bye %s", "Bug")
    console.groupEnd()
  console.groupEnd()

console.groupCollapsed("UTIL LOG")
  console.assert(true, "Hello %s", "World")
  console.time("Time")
  console.timeLog("Time")
  console.timeEnd("Time")
  console.count("Count")
  console.count("Count")
  console.countReset("Count")
  console.log({key: "value"}, "Hello", "World")
  console.dir(console.Console.prototype, {depth: 0})
  console.groupEnd()

Example using the Console class:

// If you have your own stdout or stderr
var myConsole = new console.Console(stdout, stderr)
myConsole.log("Hello World")

TIP: It is recommended that stdout and stderr be Node.js writable stream objects. In practice, they can be any object containing a write method. If you want to use console.clear, the stdout should also implement a clear method.

BrowserStdout and BrowserStderr (simulating stderr and stdout in the browser):

console.stdout // Pre-instantiated stdout
console.stderr // Pre-instantiated stderr
// You can also instantiate your own
var stdout = new console.BrowserStdout()
var stderr = new console.BrowserStderr()

This module implements the following methods (excluding details that differ from the console module):

  • label
  • info
  • warn
  • table
  • group
  • groupEnd
  • groupCollapsed
  • dirxml
  • trace
  • profile
  • profileEnd
  • timeStamp
  • debug
  • log
  • error
  • assert
  • clear
  • dir
  • count
  • countReset
  • time
  • timeLog
  • timeEnd
  • createTask
  • Console

Some methods are implemented as empty functions.

Thank you for reading. PRs are welcome!

consoleClass-browser

本模块实现了Nodejs的console模块)
起因是我在尝试在前端模拟shell时候发现console-browserify没有实现Console类
本来想提一个pr的,但是要我改的话可能就要大变动了,八成可能会被拒绝,因此我就花几个小时重写了这个模块

Usage

本模块用法与Node标准库基本相同,细节有不同
一个简单的示例(test.js)

const console = require("console-class-browser")

console.group("SIMPLE LOG")
  console.group("LOG")
    console.log("Hello %s", "World")
    console.info("Hello %s", "World")
    console.debug("Hello %s", "World")
    console.dirxml("Hello %s", "World")
    console.table("Hello %s", "World") // TODO
    console.warn("Hello %s", "World")
    console.groupEnd()
  console.group("ERROR")
    console.error("Bye %s", "Bug")
    console.trace("Bye %s", "Bug")
    console.groupEnd()
  console.groupEnd()

console.groupCollapsed("UTIL LOG")
  console.assert(true, "Hello %s", "World")
  console.time("Time")
  console.timeLog("Time")
  console.timeEnd("Time")
  console.count("Count")
  console.count("Count")
  console.countReset("Count")
  console.log({key: "value"}, "Hello", "World")
  console.dir(console.Console.prototype, {depth: 0})
  console.groupEnd()

Console类示例

// 如果你有自己的stdout或stderr
var myConsole = new console.Console(stdout, stderr)
myConsole.log("Hello World")

TIP: 建议stdout和stderr是一个nodejs的可写流对象,实际上可以是任何包含write方法的对象,如果希望console.clear还需要在stdout上实现clear方法

BrowserStdout和BrowserStderr(在浏览器上模拟stderr和stdout)

console.stdout // 已经实例化的stdout
console.stderr // 已经实例化的stderr
// 也可以自己实例化一个
var stdout = new console.BrowserStdout()
var stderr = new console.BrowserStderr()

本模块实现了以下方法(不包括与console模块不同的细节)

  • label
  • info
  • warn
  • table
  • group
  • groupEnd
  • groupCollapsed
  • dirxml
  • trace
  • profile
  • profileEnd
  • timeStamp
  • debug
  • log
  • error
  • assert
  • clear
  • dir
  • count
  • countReset
  • time
  • timeLog
  • timeEnd
  • createTask
  • Console

部分方法使用空函数实现

感谢阅读,欢迎pr补充)