Add a text encoding step to example 8.9

This commit is contained in:
Mattias Buelens
2018-06-10 00:21:07 +02:00
parent 01793f2d1f
commit cd42596d4e
+7 -3
View File
@@ -371,11 +371,13 @@ declare class Request {
readonly url: string;
}
declare class Response {
constructor(body?: ReadableStream<any>);
readonly body: ReadableStream<ArrayBufferView>;
constructor(body?: ReadableStream);
readonly body: ReadableStream;
}
declare class TextDecoderStream extends TransformStream<string, ArrayBufferView> {
}
declare class TextEncoderStream extends TransformStream<Uint8Array, string> {
}
class LipFuzzTransformer implements TransformStreamTransformer<string, string> {
substitutions: Dictionary<string>;
@@ -439,7 +441,9 @@ class LipFuzzTransformer implements TransformStreamTransformer<string, string> {
// Decode the binary-encoded response to string
.pipeThrough(new TextDecoderStream())
// Apply the LipFuzzTransformer
.pipeThrough(ts);
.pipeThrough(ts)
// Encode the transformed string
.pipeThrough(new TextEncoderStream());
return new Response(transformedBody);
})
);