Last active
December 22, 2015 18:49
-
-
Save JamesMGreene/6515080 to your computer and use it in GitHub Desktop.
Adam says so.
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
(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; | |
})(); |
Oh, also that changes line #15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I also say you should fix line #24, jQuery doesn't use the
new
operator for deferred construction.var dfd = $.Deferred()