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

sole

v0.2.10

Published

sole.js - the soul of the console - tag, glob, filter and trigger events via console messages

Downloads

11

Readme

sole.js

the soul of the console

sole.js is an extension of the console paradigm that includes tagging, filtering, globbing, plugins and event subscription.

Note: sole.js does not override the console, (however there is a plugin for that, if you wish.)

Quick start

sole.tag('my').log('stuff');

and then later

sole.filter('my')

to get just your stuff!

  • Play around with the qunit tests to see how it all works!

Wait, why do I need this?

With the ability to use semantic tagging, and filtering output of commands, you can use it for example to create unit tests, catching issues cross-browser, perfomance tuning, troubleshooting, replacing the normal console, etc... There is a plugin to generate qunit tests automatically by simply logging information at key points, check out the included qunitgenerator test!

Caveat emptor: On the surface, having console commands everywhere and tightly coupling your code with a library seems like a bad idea, however sole.js is fully tested, and used in various high-traffic production sites. If you can live with that, read on!

Using it

sole.log("Some gibberish");
sole.tag("useful").log("Useful info");
sole.filter("useful").get();
// [{ args: ["Useful info"], tags: ["useful"], type: "log" }]

ie: avoid the gibberish!

Simple example

Say we had a function Func that we wanted to test - we could use sole to capture information from it at key points in the process.

function Func(args) {
    //	Private function - we are naming the function here 
	var multiply = function multiply(num, times) {
			sole.log(num, times);
			return num * times;
		}, value = multiply(args.num, args.times);
	this.getValue = function getValue() {
		sole.log(value);
		return value;
	};
	sole.log("Ran multiply", value);
};

//	Code we want to test, including any data
var myFunc = new Func({ num: 9, times: 6 });

sole will now contain the following:

[
    {"type":"log","tags":[],"args":{"0":9,"1":6}},
    {"type":"log","tags":[],"args":{"0":"Ran multiply","1":54}}
]

You can use this to test that the output result matches the given input, ie: Func received 9, 6 and returned 54, or in other words: 9 x 6 = 54.

Tagging

sole.tag(yourTag)

Where yourTag is one of

  • string most basic form of use
  • array alternatively pass in an array of tags

tag is chainable, so you can do things like:

sole.tag("blah").log("something").get();
// [{ args: ["something], tags: ["blah"], type: "log", time: date }]

Note: Tags are persistent, so once you set a tag, it will be reused for further messages.

Globbing

Say you had:

sole.tag("fruit.apple").log("We have an apple");
sole.tag("fruit.apple.green").log("We have a green apple");

If you run

sole.glob("fruit.apple").length

Returns 1 item

sole.glob("fruit.apple*").length

Returns 2 items

Filtering

Copyright and license

Copyright 2013 jsguy (Mikkel Bergmann)

Licensed under the MIT License