Created
March 4, 2012 23:23
-
-
Save kaezarrex/1975352 to your computer and use it in GitHub Desktop.
A JavaScript function for chaining asynchronous calls.
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
function first(func) { | |
this.then = function(callback) { | |
return first(function(cb) { | |
func(function(){ | |
callback(cb); | |
}); | |
}); | |
}; | |
this.last = function(callback) { | |
func(callback); | |
}; | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what the hell.