Emit multiple data chunks from output Streams (was: Proper streaming)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32.7k
- Forks
- 1.4k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
It would be very cool if sharp could support proper streaming. As it is now, it will always emit exactly one data event which is the whole image. It kind of defeats the purposes of streams.
As I see it there is two ways to implement this.
-
The hard, but robust way.
Every time that
libvipshave data that should be written, it should call a function that we have defined. We then use this data to generate adata-event on the stream. It would be really cool iflibvipscould provide a state-machine that has a synchronous function that gives the next chunk. That waypauseandunpausewould work perfectly. -
The quick and easy fix.
We can also create a named pipe and tell
libvipsto write it to that file viavips_image_write_to_file. To the user we would then return aReadStreamas returned byfs.createReadStream(path).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the output Stream implementation and how libvips currently writes the complete image. Compare the proposed callback/state-machine approach with using a named pipe and fs.createReadStream(path). Done means output emits multiple data events while preserving usable pause and unpause behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100