fix(streams): tighten stream typings and guard optional runtime paths for duplex and wrapper utilities
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user