/* Promise */ function Promise() { this.queues = []; this.fails = []; this.progress = []; this.nextVal = null; this.nextErr = null; } Promise.prototype.then = function ( onFulfilled, onRejected, progress) { this.done.call(this, onFulfilled); if (Object.prototype.toString.call(onRejected) == "[object Function]") { this.fail.call(this, onRejected); } if (Object.prototype.toString.call(progress) == "[object Function]") { this.progress.call(this, progress); } return this; }; Promise.prototype.done = function (func) { this.queues.push(function(data) { this.nextVal = func.call(null, data); });