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 🙏

© 2025 – Pkg Stats / Ryan Hefner

conso1e

v1.2.2

Published

console wrapper + extra features

Readme

conso1e ( conso[one]e ) is a fully functional console wrapper with additional features. Since it wraps every console method, you can simply replace console with it.

Build Status codecov npm

Features

  • Supports method-chaining
  • It's stateful
  • Logs can be suppressed & bufferable
  • Provides a global & singleton instance which is accessible across modules
  • Labels
  • Subcontexts

Getting Started

Install it with NPM:

npm i conso1e

require() it and create() an instance:

const console = require('conso1e').create();
console.log('Hello');

If you want to replace console with conso1e entirely, overwrite the global console variable:

console = require('conso1e').create(); // Overwriting the builtin console object
console.log('Hello');

// You can still access the original console
// via .core property
console.core.log('Hello');

* Beware that overwriting console affects the entire application

Instead of creating a local instance, you can also use global() to access the global instance:

const console = require('conso1e').global();

global() always returns the same instance. In other words, it returns singleton.
The global instance persists across different modules.

ES module loading is also supported:

import Conso1e from 'conso1e';
const console = Conso1e.create(); // Local instance
const console = Conso1e.global(); // Global instance

Methods & Properties

.suppress ( buffer = false )

Starts suppression. During suppression, any method calls don't output to the console.
Suppression can be bypassed by prefixing methods with underscore (ex. console.log()console._log() ).

  • @param <boolean> buffer
    • If true, suppressed calls will be buffered
  • @return
    • Returns this

.unsuppress ( flush = true )

Ends suppression.

  • @param <boolean> flush
    • If true, all the buffered calls are sent to the console at once
  • @return
    • Returns this

.flush ( )

Outputs and clears the current buffers


.clearBuffers ( )

Clears the current buffers without output


.option ( name[, value] )

Sets or returns an option value by name

  • @param <string> name
    • Name of the option
  • @param <any> value
    • New value to set to the option
  • @return
    • Returns this if value is provided. Otherwise, returns the option value

Available Options:

| name | type | description | | ------------: | ------- | ------------------------------------------------------------ | | label | string | If any string is set, it appears preceding every console output. | | forceOutput | boolean | If it is true, suppression is completely ignored. |

// Example
let console = require('conso1e').create();
console.option('label', '[LABEL]');
console.log('ABC'); // '[LABEL] ABC'
console.log('DEF'); // '[LABEL] DEF'

.subcontext ( )

Creates and returns a subcontext. Subcontext is a child conso1e instance that inherits the current state and the core from the parent.

A subcontext defaults to the parent's current state and the option values. However you can override these individually.

// Example
let parent = require('conso1e').create();
let child = parent.subcontext();

parent.option('label', '[LABEL]');
parent.log('ABC'); // '[LABEL] ABC'
child.log('123');  // '[LABEL] 123' // label is inherited

child.option('label', '[SUB_LABEL]');
parent.log('ABC'); // '[LABEL] ABC'
child.log('123');  // '[SUB_LABEL] 123' // label is overriden
  • @return
    • Returns a new subcontext instance

.core

The real console object that is wrapped

@type object *(read only)


.parent

The parent conso1e instance. It is null if this is not a subcontext

@type object <conso1e> *(read only)


.isSuppressed

Whether suppression is currently active, or not

@type boolean *(read only)


.isBuffering

Whether buffering is currently active, or not

@type boolean *(read only)


.hasBuffer

Whether the console has any buffered call

@type boolean *(read only)

Advanced Usage

Custom Console

create() function has the exact same parameters as the constructor of the built-in Console class.

const debugLog = fs.createWriteStream('./debug.log');
const errorLog = fs.createWriteStream('./error.log');
const console = require('conso1e').create(debugLog, errorLog);

You can also pass a console object to wrap() :

const myConsole = new console.Console(debugLog, errorLog);
const console = require('conso1e').wrap(myConsole);

© 2020 amekusa