Created
September 13, 2012 08:00
-
-
Save dominykas/3712759 to your computer and use it in GitHub Desktop.
Promises are awesome
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
var getHtml = function (lang, pageId) | |
{ | |
var promise = Q.ninvoke(fs, "readFile", getFn(lang, pageId), UTF); | |
var onFailure = (lang == defaultLang | |
? Q.reject | |
: function () { return getHtml(defaultLang, pageId); }); | |
return promise.then(Q.resolve, onFailure); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment