Last active
September 3, 2017 06:13
-
-
Save cantremember/9d818931c610278e7cc8 to your computer and use it in GitHub Desktop.
Promises: How Many LOCs Do You Want?
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
/** | |
* 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