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 🙏

© 2026 – Pkg Stats / Ryan Hefner

commandor

v0.1.3

Published

Web Application Commands Mediator.

Readme

Commandor Build Status

Commandor simplify command/form events management by creating a single endpoint for them (implements the mediator pattern).

It introduce an app: protocol to refer to commands directly inside your HTML.

How to use Commandor

Consider this HTML snippet:

<div class="root">
	<div id="posts">
		<article>
			<h1>Post #1</h1>
			<p><a href="app:App/delete?id=1">delete</a></p>
		</article>
		<article>
			<h1>Post #2</h1>
			<p><a href="app:App/delete?id=2">delete</a></p>
		</article>
	</div>
	<form action="app:App/form">
		<p>
			My input : <input type="text" /><br />
			<input type="submit" formaction="app:App/clear" value="Clear" />
			<input type="submit" value="Submit" />
		</p>
	</form>
</div>

You can see that a[href], form[action], input[formaction] attributes are filled with app: protocol uris. It maps commands to functions. Query parameters are passed to them.

To use Commandor with this HTML, first, create a Commandor instance in your code, the rootElement can be the document body or any other DOM element :

var commandManager=new Commandor(document.querySelector('.root'));

Then register your commands :

commandManager.suscribe('App/delete',function(event,params,element) {
	console.log('Removed article #'+params['id']);
	element.parentNode.parentNode.parentNode.removeChild(
		element.parentNode.parentNode);
});
commandManager.suscribe('App/form', function(event, params, form) {
	console.log('Form submitted,'+form[0].value);
	var article=document.createElement('article');
	article.innerHTML='<h1>'+form[0].value+'</h1>'
		+'<p><a href="app:App/delete?id='+Date.now()+'">delete</a></p>';
	document.querySelector('div#posts').appendChild(article);
	form.elements[0].value='';
});
commandManager.suscribe('App/clear', function(event, params, button) {
	button.form.elements[0].value='';
});

You can also directly pass an object, it'll automatically be mapped :

var App= {
	'delete' : function(event,params,element) {
		console.log('Removed article #'+params['id']);
		element.parentNode.parentNode.parentNode.removeChild(
			element.parentNode.parentNode);
	},
	'form' : function(event, params, form) {
		console.log('Form submitted,'+form[0].value);
		var article=document.createElement('article');
		article.innerHTML='<h1>'+form[0].value+'</h1>'
			+'<p><a href="app:App/delete?id='+Date.now()+'">delete</a></p>';
		document.querySelector('div#posts').appendChild(article);
		form.elements[0].value='';
	},
	'clear' : function(event, params, button) {
		button.form.elements[0].value='';
	}
};
commandManager.suscribe('App',App);

By doing so, 'this' will be set to the parent object without having to bind methods.

To dispose a command when no longer used :

commandManager.unsuscribe('App/random');

To dispose the entire command manager (event listeners included) :

commandManager.dispose();

You can create many commandor instances to keep your code more modular or you can use namespaced commands like above.

About passed parameters to your callbacks

The first parameter is the event that leaded to the callback execution.

The second is an object containing the query string parameters.

The third parameter gives the element that delivered the executed command, it can differ from the 'event.target' property.

Samples

Here are some apps using Commandor :

Supported browsers

Firefox, Chrome, Opera and IE9+ (fully tested). Safari should be ok (not tested, DIY or buy me a Mac). IE8 by polyfilling (bind + addEventListener) (never tried).