Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
Streaming fetches are supported in Chrome, Edge, and Safari, and they look a little like this: async function getResponseSize(url) { const response = await fetch(url); const reader = response.body.getReader(); let total = 0; while (true) { const { done, value } = await reader.read(); if (done) return total; total += value.length; } } This code is pretty readable thanks to async functions (here's a
非同期処理 javascriptで非同期処理を書こうとした時、普通に処理を書くと上から書いた通りの実行順序では完了しません。非同期処理の部分が、往々にして遅延して処理が完了してしまうからです。 非同期処理として有名なものには ajax や setTimeout、XHR(XMLHttpRequest) が存在します。 コマンドライン上で実行する簡単な例を書くと $ node > console.log('hello'); console.log('world'); hello world undefined > setTimeout(() => console.log('hello'), 500); console.log('world'); world undefined > hello 普通に連続で書くとhello と world が順序通り表示されますが、setTimeoutを使った方
byMostafa Gaafar@mgaafarSoftware Engineer @ Amazon London. Likes scalable distributed stuff & JavaScript
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く