Skip to content

Instantly share code, notes, and snippets.

@JamesMGreene
Last active December 22, 2015 18:49
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 JamesMGreene/6515080 to your computer and use it in GitHub Desktop.
Save JamesMGreene/6515080 to your computer and use it in GitHub Desktop.
Adam says so.
(function() {
// Duck punch that mofo
$.Deferred = (function(deferredDef) {
var slicer = [].slice;
var adamSaysSo = function(truthy) {
var args = slicer.call(arguments, 1);
return this[truthy ? 'resolve' : 'reject'].apply(this, args);
};
return function(beforeStart) {
var dfd = deferredDef(beforeStart);
dfd.adamSaysSo = adamSaysSo;
return dfd;
};
})($.Deferred);
var dfd = new $.Deferred();
return dfd;
})();
@adamterlson
Copy link

I also say you should fix line #24, jQuery doesn't use the new operator for deferred construction. var dfd = $.Deferred()

@adamterlson
Copy link

Oh, also that changes line #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment