Skip to content

Instantly share code, notes, and snippets.

@chemdemo
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemdemo/01af494a9e52154827bf to your computer and use it in GitHub Desktop.
Save chemdemo/01af494a9e52154827bf to your computer and use it in GitHub Desktop.
mini Promise
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