An object with all the same methods as console in the browser. But does nothing.
Last updated 7 years ago by henrikjoreteg .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install mockconsole 
SYNC missed versions from official npm registry.


What is this?

A tiny browser module that builds and returns an object with the same methods as console but with no-op functions.

Suitable for use with browserify/CommonJS on the client.

If you want to use as a standalone or with AMD use mockconsole.umd.js.

Can be handy for modules that export constructors where you wnat to be able to pass in a logger as an option.


npm install mockconsole

Demo / How to use it

var mockconsole = require('mockconsole');

// this way someone can pass in `window.console` or something
// like as the logger for logging
// If it's not passed in no code needs to change.
function Human(options) {
    this.console = options.logger || mockconsole;
} = function () {
    this.console.log('dance human!');   



Created By

If you like this, follow: @HenrikJoreteg on twitter.

Current Tags

  • 0.0.1                                ...           latest (7 years ago)

1 Versions

  • 0.0.1                                ...           7 years ago

Copyright 2014 - 2017 © |