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

tiny-deferred

v1.0.0

Published

A tiny deferred object constructor

Readme

tiny-deferred

Does what it says on the tin and does it well. That is all.

Howto

The only events are done, fail and always.

var def = new Deferred()
	.done(function() {
			console.log('Great success!');
		})
	.fail(function() {
			console.log('Dang.');
		})
	.always(function() {
			console.log('Always clean up after yourself.');
		});

Once an instance has been resolved or rejected, it can't be resolved or rejected again. However, adding a done, fail or always callback to a rejected object will result in the callback function being called immediately with the expected arguments and context.

def.resolve({
	message: 'Very important message.'
});

// Many lines of code later...
def.done(function(response) {
		console.log(response.message); // Logs 'Very important message' immediately.
	})
	.fail(function() {
		console.log(response.error); // Will never be called. In fact, the callback is discarded immediately.
	})
	.always(function() {
		console.log('All over.'); // Called immediately after the done callback above.
	});

Returning any kind of value (null included) from a callback will cause that value to be passed as the first argument to subsequent callbacks. This feature allows us to create an interesting onion-skin pattern, morphing data as it passes through the layers of callbacks.

def.done(function(response) {
		return templateEngine.render('my-template', response);
	});

// Many lines of code later...
def.done(function(html) {
		document.body.innerHTML = html;
	});

Context can be supplied to callbacks by calling the resolveWith or rejectWith methods. The context is the same for all callbacks, even those added and fired after resolution or rejection.

new Deferred()
	.done(function(message) {
		this.log(message); // Logs 'Hai' to the console.
	})
	.resolveWith(console, 'Hai');

Arrays of functions may be passed to the callback methods.