chromium/third_party/blink/web_tests/external/wpt/fetch/api/response/response-stream-disturbed-util.js

const BODY = '{"key": "value"}';

function responseFromBodySource(bodySource) {
  if (bodySource === "fetch") {
    return fetch("../resources/data.json");
  } else if (bodySource === "stream") {
    const stream = new ReadableStream({
      start(controller) {
        controller.enqueue(new TextEncoder().encode(BODY));
        controller.close();
      },
    });
    return new Response(stream);
  } else {
    return new Response(BODY);
  }
}