To chain you need to return an object that either has the next method as own property or somewhere in its prototype chain. I will make a simple calculator for you:
function calculator(){
this.ledger = [];
this.timeout = 0;
this.callback = function(x){console.log(x)};
}
calculator.prototype.add = function(v){
v = +v;
v = v !== v ? 0 : v;
clearTimeout(this.timeout);
this.timeout = setTimeout((function(){this.callback(this.ledger.reduce(function(ac,d){return ac +d})); this.ledger = [];}).bind(this),0);
this.ledger.push(v);
return this;
}
var x = new calculator;
x.add(1).add().add(0); //1
x.add(5).add(-2).add(3); //6