fix(streams): tighten stream typings and guard optional runtime paths for duplex and wrapper utilities

This commit is contained in:
2026-04-30 12:04:51 +00:00
parent f78469a299
commit fccd0f86ad
19 changed files with 1687 additions and 4247 deletions
+7 -4
View File
@@ -1,13 +1,13 @@
import { expect, tap } from '@push.rocks/tapbundle';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { WebDuplexStream } from '../ts_web/index.js';
// Helper: collect all chunks from a readable
async function collectAll<T>(reader: ReadableStreamDefaultReader<T>): Promise<T[]> {
const results: T[] = [];
while (true) {
const { value, done } = await reader.read();
if (done) break;
results.push(value);
const result = await reader.read();
if (result.done) break;
results.push(result.value);
}
return results;
}
@@ -70,6 +70,9 @@ tap.test('WebDuplexStream: fromUInt8Array should produce data', async () => {
const { value } = await reader.read();
expect(value).toBeTruthy();
if (!value) {
throw new Error('Expected fromUInt8Array to produce data');
}
expect(value.length).toEqual(5);
});