fix(WebDuplexStream): Fix variable naming inconsistency in WebDuplexStream test

This commit is contained in:
2024-10-14 13:55:14 +02:00
parent 6a2ef1b152
commit e138bca39d
4 changed files with 14 additions and 8 deletions

View File

@ -28,22 +28,22 @@ tap.test('WebDuplexStream should handle transform with a write function', async
const input = [1, 2, 3, 4, 5];
const expectedOutput = [2, 4, 6, 8, 10];
const transformStream = new webstream.WebDuplexStream<number, number>({
const webDuplexStream = new webstream.WebDuplexStream<number, number>({
writeFunction: async (chunk, { push }) => {
// Push the doubled number into the stream
push(chunk * 2);
},
});
const writableStream = transformStream.writable.getWriter();
const readableStream = transformStream.readable.getReader();
const writer = webDuplexStream.writable.getWriter();
const reader = webDuplexStream.readable.getReader();
const output: number[] = [];
// Read from the stream asynchronously
const readPromise = (async () => {
while (true) {
const { value, done } = await readableStream.read();
const { value, done } = await reader.read();
if (done) break;
if (value !== undefined) {
output.push(value);
@ -53,9 +53,9 @@ tap.test('WebDuplexStream should handle transform with a write function', async
// Write to the stream
for (const num of input) {
await writableStream.write(num);
await writer.write(num);
}
await writableStream.close();
await writer.close();
// Wait for the reading to complete
await readPromise;