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

defferedjs

v1.0.1

Published

basic twwisted.web nodejs implementation

Readme

Defer.js

A very ligthweigth twisted.web type implementation for node.js for full async progamming

install: (not packaged yet. Coming very soon !)

npm defer

sample usage:

The difference between chained defers and defered lists is that chain defer wil take the output value of the last callback to the next and defered_lists will take args as argument and will input those args on the callback or errback

add callbacks and errback
var defer = require('./index.js')
// var defer = require('defer')
function _cb(value){
var ret = value *2;
console.log("ret1: "+ ret);
return ret;
}
function _eb(err, value){
console.log("err : "+ err);
return err;
}
function _main(a){	
var d = defer.Deferred();
var b =2;
var ret = a+b;
d.addCallback(_cb);
d.addCallback(_cb);
d.addErrback(_eb);
d.returnValue(ret);
}
_main(1);
>> Will output 6 and 12
add promises and use fallback on rejection
//Promises will compare the output value of a callback returning a boolean. If the condition is true the promise will fire next callback if not it will fire the fallback.
//Syntax: addPromise([<operator>, <value>],[<operator>, <value>] )
//Note that multiple argument array will pass each condition in turn and will fire callback only if all returned true. 
//Let's use callbacks and fallbacks and errbacks in the same logic
function _main3(a){
function _cb(value){
var ret = value *2;
console.log("ret1: "+ ret);
return ret;
}
function _eb(err, value){
console.log("err : "+ err);
return err;
}
function _fb(value){
var ret = value +1;
console.log("ret fb: "+ ret);
return ret;
}
console.log("Starting main3 example function");		
var d = defer.Deferred();
var b =2;
var ret = a+b;
d.addCallback(_cb);
d.addFallback(_fb);
d.addPromise(["<","6"]);
d.addErrback(_eb);
d.returnValue(ret);
}
_main3(1);
>> output promise has succeded value (1+2) was lower than 6 and then it fired_fb that added 1 = output 4

add defered_list callbacks and errbacks

var defer = require("./index.js");
// var defer =  require('defer');

function _cb(value){
    var ret = value *2;
    console.log("ret1: "+ ret);
    return ret;
}
function _fb(value){
var ret = value +1;
console.log("ret fb: "+ ret);
return ret;
}
function _cb222(value, value2){
    var ret = value *2+value2;
    console.log("ret222: "+ ret);
    return ret;
}
function _cb2(value){
    var ret = value *2;
    console.log("ret2: "+ ret);
    return ret;
}
function _cb3(value){
    var ret = value *2;
    console.log("ret3: "+ ret);
    return ret;
}
function _cb4(value){
    var ret = value *2;
    console.log("ret4: "+ ret);
    return ret;
}
function _eb(err, value){
    console.log("err : "+ err);
    return err;
}
function _eb2(err, value){
    console.log("err : "+ err);
    return err;
}
//Let's chain our callbacks that must pass its return value to the next one
// <defered object>.defered_list_addCallback(callback)
// <defered object>.defered_list_addErrback(errback)
// will fire in case of a undefined or null value or not function cb or err
function _main(a){
	var d = defer.Deferred();
	var b =2;
	var ret = a+b;
	d.addCallback(_cb);
	d.addCallback(_cb2);
	d.addCallback(_cb3);
	d.addCallback(_cb4);
	d.addErrback(_eb);
	d.addErrback(_eb2);
	d.returnValue(ret);
}
_main(1);// output 6 12 24 48

//Let's pile our callbacks that must be resolved independently ans will take their own arguments
// <defered object>.defered_list_addCallback(callback, [args])
// <defered object>.defered_list_addErrback(errback, [args])
// will fire in case of a undefined or null value or not function cb or err
function _main2(a){
	var dl = defer.defered_list();
	var b =2;
	var ret = a+b;
	dl.defered_list_addCallback(_cb222, [1,2]);
	dl.defered_list_addCallback(_cb2 , [1]);
	dl.defered_list_addCallback(_cb3, [1]);
	dl.defered_list_addCallback(_cb4, [1]);
	dl.defered_list_addErrback(_eb, [1]);
	dl.defered_list_addErrback(_eb2, [1]);
	dl.defered_list_returnValue(ret);
}
_main2(1);// output 4 2 2 2
//Let's use callbacks and fallbacks and errbacks in the same logic
function _main3(a){
console.log("Starting main3 example function");		
var d = defer.Deferred();
var b =2;
var ret = a+b;
d.addCallback(_cb);
d.addFallback(_fb);
d.addPromise(["<","6"]);
d.addErrback(_eb);
d.returnValue(ret);
}
_main3(1);// output promise has succeded value (1+2) was lower than 6 and then it fired_fb that added 1 = output 4

Tests:

Install mocha globally to use it from terminal
npm install mocha -g
then do the following command in the node-modules root
mocha