chore: embrace web streams #20

Open
opened 2025-08-01 08:55:52 -07:00 by clo · 2 comments
Owner

port the following functions

  • fs.createReadStream(file): ReadableStream should add to #sitegen/fs
  • fs.createWriteStream(file): ReadableStream should add to #sitegen/fs
  • crypto.createHash(algo, WritableStream): Promise<string>
  • zlib.createGzip() -> CompressionStream
  • zlib.createZstdCompress(): TransformStream
  • stream.promises.pipeline probably just use the built-in API
  • child_process.spawn should add to #sitegen/subprocess
  • readline.createInterface(): TransformStream can derive from https://jsr.io/@std/streams/1.0.12/text_line_stream.ts
  • all code using the above

the node.js ones will probably have to be homegrown. either as wrappers around the node.js apis or whatever. it might be cute to see if other runtimes can be supported.

this can be done with more "overlay" modules like #sitegen/fs

port the following functions - [ ] `fs.createReadStream(file): ReadableStream` *should add to `#sitegen/fs`* - [ ] `fs.createWriteStream(file): ReadableStream` *should add to `#sitegen/fs`* - [ ] `crypto.createHash(algo, WritableStream): Promise<string>` - [ ] `zlib.createGzip()` -> CompressionStream - [ ] `zlib.createZstdCompress(): TransformStream` - [ ] `stream.promises.pipeline` *probably just use the built-in API* - [ ] `child_process.spawn` *should add to `#sitegen/subprocess`* - [ ] `readline.createInterface(): TransformStream` *can derive from https://jsr.io/@std/streams/1.0.12/text_line_stream.ts* - [ ] all code using the above the node.js ones will probably have to be homegrown. either as wrappers around the node.js apis or whatever. it might be cute to see if other runtimes can be supported. this can be done with more "overlay" modules like `#sitegen/fs`
clo changed title from embrace web streams to chore: embrace web streams 2025-08-03 19:01:08 -07:00
Author
Owner

i've started with new reading helpers at work (streams.BufferedReader), which is quite useful. the fact it works on browser fetch is probably a reason i should slowly move all work to it.

i've started with new reading helpers at work (streams.BufferedReader), which is quite useful. the fact it works on browser fetch is probably a reason i should slowly move all work to it.
Author
Owner

this is great because many of these will be added as libraries under lib, which can be tailored to work in the browser and on the server. for example, lib's future crypto.HashStream can buffer in the web browser, but stream in native code.

this is great because many of these will be added as libraries under `lib`, which can be tailored to work in the browser and on the server. for example, lib's future `crypto.HashStream` can buffer in the web browser, but stream in native code.
Sign in to join this conversation.
No labels
bug
chore
feat
lib
site
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: clo/sitegen#20
No description provided.