mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision b464d69274950c7707855c0b29729d58b9a8d492
This commit is contained in:
parent
93c31df551
commit
b505991695
92 changed files with 1750 additions and 119 deletions
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
// Read all the chunks from a stream that returns BufferSource objects and
|
||||
// concatenate them into a single Uint8Array.
|
||||
async function concatenateStream(readableStream) {
|
||||
const reader = readableStream.getReader();
|
||||
let totalSize = 0;
|
||||
const buffers = [];
|
||||
while (true) {
|
||||
const { value, done } = await reader.read();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
buffers.push(value);
|
||||
totalSize += value.byteLength;
|
||||
}
|
||||
reader.releaseLock();
|
||||
const concatenated = new Uint8Array(totalSize);
|
||||
let offset = 0;
|
||||
for (const buffer of buffers) {
|
||||
concatenated.set(buffer, offset);
|
||||
offset += buffer.byteLength;
|
||||
}
|
||||
return concatenated;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue