批处理


🌐 Batching

每次迭代会产生一个批次——一个包含 Uint8Array 个块(Uint8Array[])的数组。批处理可以将 await 和 Promise 创建的成本分摊到多个块上。每次处理一个块的消费者可以简单地迭代内部数组:

🌐 Each iteration yields a batch -- an array of Uint8Array chunks (Uint8Array[]). Batching amortizes the cost of await and Promise creation across multiple chunks. A consumer that processes one chunk at a time can simply iterate the inner array:

for await (const batch of source) {
 for (const chunk of batch) {
 handle(chunk);
 }
}async function run() {
 for await (const batch of source) {
 for (const chunk of batch) {
 handle(chunk);
 }
 }
}

AltStyle によって変換されたページ (->オリジナル) /