Last active
August 29, 2015 14:19
-
-
Save wanderview/16f2839ba57514a625c4 to your computer and use it in GitHub Desktop.
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
myStream.read(function handleChunk(chunk) { | |
if (!chunk) { | |
processDone(); | |
return; | |
} | |
processChunk(chunk); | |
myStream.read(handleChunk); | |
}); |
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
myStream.read().then(function handleChunk(chunk) { | |
if (!chunk) { | |
return; | |
} | |
processChunk(chunk); | |
return myStream.read().then(handleChunk); | |
}).then(processDone); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code (more similar to your callback code) would also not have this problem: