Skip to content

Instantly share code, notes, and snippets.

@djfarrelly
Last active August 29, 2015 14:02
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 djfarrelly/e7c95ee2762d157d9bcf to your computer and use it in GitHub Desktop.
Save djfarrelly/e7c95ee2762d157d9bcf to your computer and use it in GitHub Desktop.
shorten function
// ==================== Existing =========================================
shorten: function(url, callback, reshortenLink) {
// ...
},
// called
Shortener.shorten('site.com/some/url', function(){
// more logic
}, true)
// ==================== Alertnate =========================================
// Potentially currying the functions so the last arg is always the callback
// reshortenLink is an optional param
shorten: function(url, reshortenLink, callback) {
if (typeof reshortenLink === 'function'){
callback = reshortenLink;
reshortenLink = null;
}
// ...
},
// called
Shortener.shorten('site.com/some/url', function(){
// more logic
})
// or
Shortener.shorten('site.com/some/url', true, function(){
// more logic
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment