text-encode-transform
The text-encode-transform built-in module is available to use in your EdgeWorkers code bundles. It exports implementations of TextEncoderStream and TextDecoderStream, as described in the WhatWG encoding specification.
import { httpRequest } from 'http-request';
import { createResponse } from 'create-response';
import { TextEncoderStream, TextDecoderStream } from 'text-encode-transform';
export function responseProvider (request) {
return httpRequest(`${request.scheme}://${request.host}${request.url}`).then(response => {
return createResponse(
response.status,
response.headers,
response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new TextEncoderStream())
);
});
}
Updated almost 3 years ago