show me an example of code using TransformStream in JS
- User
show me an example of code using TransformStream in JS
Assistant
Sure, here is an example of code using TransformStream in JS:
javascriptconst readableStream = new ReadableStream({ start(controller) { const chunks = [ "Hello, ", "world!", ]; for (const chunk of chunks) { controller.enqueue(chunk); } controller.close(); }, }); const transformStream = new TransformStream({ transform(chunk, encoding, callback) { const transformedChunk = chunk.toUpperCase(); callback(null, transformedChunk); }, }); readableStream.pipeThrough(transformStream).on("data", (chunk) => { console.log(chunk); });
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.