spirobel
spirobel
Explore posts from servers
DDeno
Created by it's em! on 1/29/2024 in #help
How can I flush a stream to a response?
nvm had to add { headers: { "content-type": "text/html; charset=utf-8" } } and now it works
7 replies
DDeno
Created by it's em! on 1/29/2024 in #help
How can I flush a stream to a response?
is there are full working example? cant get my deno to flush 😳
7 replies
DDeno
Created by spirobel on 2/25/2024 in #help
How to feed a ReadableStream / async Generator into a Response object?
(while sending the Hello instantly) EDIT: with { headers: { "content-type": "text/html; charset=utf-8" } } it works
9 replies
DDeno
Created by spirobel on 2/25/2024 in #help
How to feed a ReadableStream / async Generator into a Response object?
it waited 5 seconds and then sent the whole Hello world. I thought it would send Hello, then wait for 5 seconds and then send the world! 😀
9 replies
DDeno
Created by spirobel on 2/25/2024 in #help
How to feed a ReadableStream / async Generator into a Response object?
is there something special I need to do to flush the buffers after every yield? I tried this:
javascript
Deno.serve(
(request) =>
new Response(
ReadableStream.from(makeStream(request)).pipeThrough(
new TextEncoderStream()
)
)
);
const wait = (n: number) => new Promise((resolve) => setTimeout(resolve, n));

async function* makeStream(request) {
yield "Hello,";
console.log("start wait ");
await wait(5000);
yield "world!";
}
javascript
Deno.serve(
(request) =>
new Response(
ReadableStream.from(makeStream(request)).pipeThrough(
new TextEncoderStream()
)
)
);
const wait = (n: number) => new Promise((resolve) => setTimeout(resolve, n));

async function* makeStream(request) {
yield "Hello,";
console.log("start wait ");
await wait(5000);
yield "world!";
}
9 replies
DDeno
Created by spirobel on 2/25/2024 in #help
How to feed a ReadableStream / async Generator into a Response object?
thanks a lot for your reply! I didn't know yielding buffers or strings mattered. this is great info!
9 replies
DDeno
Created by spirobel on 2/25/2024 in #help
How to feed a ReadableStream / async Generator into a Response object?
9 replies
DDeno
Created by spirobel on 2/25/2024 in #help
How to feed a ReadableStream / async Generator into a Response object?
No description
9 replies
DDeno
Created by spirobel on 2/25/2024 in #help
How to feed a ReadableStream / async Generator into a Response object?
another try using the node:stream Readable. works in bun does not work in deno
9 replies