Skip to content

Instantly share code, notes, and snippets.

@ry
Forked from felixge/fab-promise.js
Created January 26, 2010 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ry/287389 to your computer and use it in GitHub Desktop.
Save ry/287389 to your computer and use it in GitHub Desktop.
function loadConfig() {
return posix.cat('config.json')(function(error, config) {
return posix.cat('configuration.json')
})(function(error, config) {
if (error) {
sys.puts("Can't load config");
// if there is an error then it has to be returned
// otherwise the error is thrown
return error;
}
return JSON.parse(config);
})
}
function loadConfig() {
return posix.cat('config.json')
.addErrback(function(err) {
return posix.cat('configuration.json');
})
.addCallback(function(config) {
return JSON.parse(config);
})
.addErrback(function(err) {
sys.puts("Can't load config");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment