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

neat-dump

v1.0.17

Published

Neat multi-purpose tool to display values on browser or console

Downloads

77

Readme

Wigy's Neat Dump

This is a tool to display logging messages and debugging values to the browser console or to the Node terminal.

Installing

Add it to the project

npm install neat-dump --save

In the browser

For example, in your HTML-page, simply use it like

<html>
  <head>
    <script src="node_modules/neat-dump/neat-dump.js"></script>
  </head>
    <body>
    See the console...
    <script>
      var obj = {name: "Some Name", value: 1.23};
      d("Obj value is", obj, "and value of PI is", Math.PI);
    </script>
  </body>
</html>

alt text

You can use it in the middle of the expression to dump values, since it returns the value of the last argument

   var a = 2, b = 3;
   result = Math.sqrt(d(a * a + b * b));

alt text

It has different message levels

By default the message is debug message. However also other levels of messages are supported.

    d("Value of the PI is", Math.PI);
    d("Dumping configuration is", d.config);
    d.info("This is an informative message.");
    d.warning("This is a warning message.");
    d.error("This is an error message.");

alt text

In addition, one can use d.fatal() to throw an exception in addition to showing the message.

Works in Node

You can load it as a Node-module and use it to display values on the terminal running the Node-application:

    var d = require('node_modules/neat-dump/neat-dump.js');

    var conf = {port: 2000, mode: "debug"};
    d("Our application is starting with the configuration", conf);
 12:17:04 DEBUG:  ------------- /home/wigy/neat-dump/test-node.js:6:1 -------------
 12:17:04 DEBUG:  Our application is starting with the configuration {mode: "debug", port: 2000}

Configuring and turning it off in production

The utility is configurable. You can mute it completely for the production use for example:

    d.config.beQuiet = true;

The configuration has also some auto-detected flags. The d.config has

  • hasNode - Set if we are in the Node environment.
  • hasBrowser - Set if we are in the browser environment.
  • beQuiet - When set, we don't output anything.
  • showSourceLine - When set, show the line, which has called dumping.
  • showStackTrace - When set, show also full stack trace when values are dumped.
  • showTimestamp - When set, include the time stamp in every line displayed.
  • showErrorLevel - When set, include error level every line displayed.
  • showFunctions - When set, show also functions.
  • debugTesting - When set, messages are also displayed when running unit-tests.
  • displayFunction - A function handling the actual showing of the message.

Using different channels

You can define different channels that can be turned on and off independently. This is useful for adding debuggin information for some particular module. To define channels you call d.channels() and give channel names mapped to flags if they are turned on or off. To use channels, you add the name of the string as the first parameter to the d() call. If the first parameter does not match any defined channels, then channel GENERIC is used. It can also be turned off when setting channels just like any other channel.

    d.channels({
        NETWORK: true,
        CORE: true
    });
    d.config.showSourceLine = false;
    d("CORE", "Launching the application.");
    d("NETWORK", "Connecting to the server...");
    d("NETWORK", "We are connected.");
    d("Something else.");
 13:46:11 DEBUG: [CORE] Launching the application.
 13:46:11 DEBUG: [NETWORK] Connecting to the server...
 13:46:11 DEBUG: [NETWORK] We are connected.
 13:46:11 DEBUG: [GENERAL] Something else.

In shared libraries, you can just define channels and leave their settings to be decided by the application by passing values null. For example

    d.channels({
        MODULE1: null,
        MODULE2: null
    });

It can be used in unit-testing

In unit testing you can check what messages has been received. Call d.expect() with the function implementing the test and it return an expectation object you can use to check various things. With toBe() you can check the exact text of messages in the strict order:

d.expect(function(){
    function my(num) {
        d("Number was", num);
    }
    my(7);
    my(-1);
}).toBe("Number was 7", "Number was -1");

Special channels are ignored, when testing messages.

To just check that there are messages, one can use:

d.expect(function(){
    d.error("Test error.");
}).toHaveMessages();

Negated test is also supported:

d("Testing not...");
d.expect(function(){
    /* No messages */
}).not.toHaveMessages();

Future Ideas

  • Add (automatic but) configurable support for https://github.com/CodeSeven/toastr in browser.