Skip to content

Commit 1390676

Browse files
author
mux-bot
committed
refactor: remove unused streamToUint8Array helper
The streamToUint8Array helper in src/node/runtime/streamUtils.ts had zero references anywhere in the repository (verified via git grep across all tracked files). It was orphaned after the experimental image-editing tool work (#3282) that introduced it. Removing it is behavior-preserving: the function uses only global APIs, so no imports needed cleanup, and the file's other exports (shescape, streamToString) are unaffected.
1 parent 472435a commit 1390676

1 file changed

Lines changed: 0 additions & 44 deletions

File tree

src/node/runtime/streamUtils.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -43,47 +43,3 @@ export async function streamToString(stream: ReadableStream<Uint8Array>): Promis
4343
reader.releaseLock();
4444
}
4545
}
46-
47-
/** Convert a ReadableStream<Uint8Array> to one concatenated Uint8Array. */
48-
export async function streamToUint8Array(
49-
stream: ReadableStream<Uint8Array>,
50-
maxBytes?: number
51-
): Promise<Uint8Array> {
52-
const reader = stream.getReader();
53-
const chunks: Uint8Array[] = [];
54-
let totalLength = 0;
55-
56-
let completed = false;
57-
try {
58-
while (true) {
59-
const { done, value } = await reader.read();
60-
if (done) {
61-
completed = true;
62-
break;
63-
}
64-
const nextLength = totalLength + value.length;
65-
if (maxBytes != null && nextLength > maxBytes) {
66-
throw new Error(`Stream exceeded ${maxBytes} byte limit`);
67-
}
68-
chunks.push(value);
69-
totalLength = nextLength;
70-
}
71-
} finally {
72-
if (!completed) {
73-
try {
74-
await reader.cancel();
75-
} catch {
76-
// Stream may already be errored or canceled.
77-
}
78-
}
79-
reader.releaseLock();
80-
}
81-
82-
const output = new Uint8Array(totalLength);
83-
let offset = 0;
84-
for (const chunk of chunks) {
85-
output.set(chunk, offset);
86-
offset += chunk.length;
87-
}
88-
return output;
89-
}

0 commit comments

Comments
 (0)