Last active
December 22, 2015 18:49
-
-
Save adamterlson/6515332 to your computer and use it in GitHub Desktop.
jQuery conditional deferred rejection and resolution based on boolean
This file contains 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
$.Deferred = (function (baseDeferred) { | |
var slicer = [].slice; | |
var cond = function (truthy) { | |
return this[truthy ? 'resolve' : 'reject'].apply(this, slicer.call(arguments, 1)); | |
}; | |
return function() { | |
var dfd = baseDeferred.apply(this, arguments); | |
dfd.cond = cond; | |
return dfd; | |
}; | |
})($.Deferred); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment