Created
May 20, 2021 09:26
-
-
Save prakashsvmx/192960edbe8488c5704be4a63912d767 to your computer and use it in GitHub Desktop.
This file contains 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
function getResponseSize(url) { | |
return fetch(url).then(response => { | |
const reader = response.body.getReader(); | |
let total = 0; | |
return reader.read().then(function processResult(result) { | |
if (result.done) return total; | |
const value = result.value; | |
total += value.length; | |
console.log('Received chunk', value); | |
return reader.read().then(processResult); | |
}) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment