Last active
August 29, 2015 14:02
-
-
Save chemdemo/01af494a9e52154827bf to your computer and use it in GitHub Desktop.
mini Promise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = function () { | |
this.thens = []; | |
}; | |
Promise.prototype = { | |
resolve: function () { | |
var t = this.thens.shift(), n; | |
t && (n = t.apply(null, arguments), n instanceof Promise && (n.thens = this.thens)); | |
}, | |
then: function (n) { | |
return this.thens.push(n), this; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment