Skip to content

Instantly share code, notes, and snippets.

@cantremember
Last active September 3, 2017 06:13
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 cantremember/9d818931c610278e7cc8 to your computer and use it in GitHub Desktop.
Save cantremember/9d818931c610278e7cc8 to your computer and use it in GitHub Desktop.
Promises: How Many LOCs Do You Want?
/**
* fewer lines, sure ...
*/
function _sameLineStyle() {
return example.firstMethod().then(function() {
return example.secondMethod();
}).then(function() {
return example.thirdMethod();
});
}
/**
* yet i prefer this
* what a subtle change a little \n can make
*/
function _newLineStyle() {
return example.firstMethod()
.then(function() {
return example.secondMethod();
})
.then(function() {
return example.thirdMethod();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment