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

simple-console

v0.1.1

Published

A small, cross-browser-friendly console wrapper.

Downloads

7

Readme

Simple Console

Provides a simple, but useful cross-browser-compatible console logger.

Build Status Coverage Status

Sauce Test Status

Features

  • Proxies to native functionality wherever possible.
  • Enables .apply and .bind usage with console.OPERATION.
  • Buildable from straight CommonJS source.
  • Available as minified distributions as well.

Installation

Install via npm:

$ npm install simple-console

or bower:

$ bower install simple-console

Usage

Import the SimpleConsole class into your code (via AMD, CommonJS, etc) and use as a drop-in replacement for console.OPERATION. Creating a new object does not effect the existing window.console object.

AMD

define(["simple-console"], function (SimpleConsole) {
  var con = new SimpleConsole();
  con.log("Hello world!");
});

CommonJS

var SimpleConsole = require("simple-console");
var con = new SimpleConsole();
con.log("Hello world!");

VanillaJS

In your HTML:

<!-- Option One: Minified -->
<script src="PATH/TO/simple-console/dist/simple-console.min.js"></script>

<!-- Option Two: Raw source -->
<script src="PATH/TO/simple-console/simple-console.js"></script>

In your JS:

var con = new window.SimpleConsole();
con.log("Hello world!");

Noop Logger

There are some cases where you will want to conditionally silence the logger. You can do this by passing setting the noop option:

var con = new SimpleConsole({ noop: true });
con.log("Hello world!"); // => Should _not_ output anything.

This is usually useful in a case where you build different capabilities based on some external information, for example, React-style, this could be something like:

var con = new SimpleConsole({
  noop: process.env.NODE_ENV === "production"
});

con.log("Hello world!"); // => Should _not_ output anything in `production`.

Polyfill

If you are looking to polyfill console, then you can:

new SimpleConsole({ patch: true });

This will mutate the window.console object in ways that are not easily undone, so consider this a "one way" patch. Moreover, if window.console does not exist, it will create the object.

You can even go further and patch and noop the logger with:

new SimpleConsole({ patch: true, noop: true });

which ensures that nothing logs anything.

Note: In addition to filling/patching missing behavior, the polyfill will replace behavior that already exists and works. This is presently due to complexities likely normalizing and ensuring things like .bind, .apply and .call work on all log methods.

Development

Run checks, then development server:

$ gulp

Separated:

$ gulp check
$ gulp dev

Node demo:

$ node examples/demo.js

Navigations:

  • Test Page: http://127.0.0.1:4321/test/test.html
  • Demo Page: http://127.0.0.1:4321/examples/demo.html

Release process:

  • Bump versions in package.json, bower.json
  • Run npm run-script everything
  • Edit HISTORY.md
  • Run gulp check:all

Also See

Similar projects that can help with console:

License

Copyright 2015 Formidable Labs, Inc. Released under the MIT License,