Skip to content

Instantly share code, notes, and snippets.

@seidtgeist
Last active December 26, 2015 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seidtgeist/7217874 to your computer and use it in GitHub Desktop.
Save seidtgeist/7217874 to your computer and use it in GitHub Desktop.
function couldThrow(hopefullyJSON) {
var object = JSON.parse(hopefullyJSON);
return Promise.fulfilled(object);
}
function safe(hopefullyJSON) {
return Promise.fulfilled().then(function() {
return couldThrow(hopefullyJSON);
});
}
@domenic
Copy link

domenic commented Oct 29, 2013

var safe = Q.fbind(JSON.parse);

@seidtgeist
Copy link
Author

Bluebird & JS verbosity argument

partial application:

safe = bluebirdTry jsonParse

js:

var safe = bluebirdTry.bind(null, jsonParse)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment