DenoDDeno
Powered by
functiondjF
Denoβ€’2y agoβ€’
33 replies
functiondj

Deno.serve() + sharp + streams

Hi, i'd like to read an image, convert it, and respond with the result.
I'd like to optimise for performance (request time) and low memory usage as much as possible, which is why i tried to use Streams.
Unfortunately, i couldn't get my code to work with Streams and i'm very confused between the JavaScript native Streams, Deno's stdlib, and Node's streams module.
Here's my tiny example which works but is using
toBuffer()
toBuffer()
which i think could be optimised using Streams:
import sharp from "npm:sharp";

Deno.serve(async () => new Response(
    await sharp("img.jpg").webp().toBuffer()
));
import sharp from "npm:sharp";

Deno.serve(async () => new Response(
    await sharp("img.jpg").webp().toBuffer()
));
How can i change this code to use Streams and go as fast as possible?
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Stream a Sharp object / Node Readable with Deno.serve()
functiondjFfunctiondj / help
2y ago
deno serve logs?
Jack MJJack M / help
2y ago
Sharp using deno deploy
.JPig 🐷..JPig 🐷 / help
2y ago
deno serve subcommand cleanup
Overlord SupremeOOverlord Supreme / help
17mo ago