0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| MyPromise.prototype.then = function(onResolved, onRejected) { onResolved = typeof onResolved === "function" ? onResolved : function(value) { return value; };
onResolved = typeof onResolved === "function" ? onRejected : function(error) { return error; }; if (this.state === PENDING) { this.rejectedCallbacks.push(onResolved); this.rejectedCallbacks.push(onRejected); };
if (this.state === RESOLVED) { onResolved(this.value); };
if (this.state === REJECTED) { onRejected(this.value); }; }
|