tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

response-stream-disturbed-util.js (448B)


      1 const BODY = '{"key": "value"}';
      2 
      3 function responseFromBodySource(bodySource) {
      4  if (bodySource === "fetch") {
      5    return fetch("../resources/data.json");
      6  } else if (bodySource === "stream") {
      7    const stream = new ReadableStream({
      8      start(controller) {
      9        controller.enqueue(new TextEncoder().encode(BODY));
     10        controller.close();
     11      },
     12    });
     13    return new Response(stream);
     14  } else {
     15    return new Response(BODY);
     16  }
     17 }