#20chore: embrace web streams

  • avatar~clovercommented · 1 year ago
    Author
    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

  • avatar~clover changed the status to Todo · 1 year ago
  • avatar~clovercommented · 1 year ago
    Author
    Owner

    Forgejo: title changed.

    old_title: embrace web streams

    new_title: chore: embrace web streams

  • avatar~clovercommented · 1 year ago
    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.

  • avatar~clover added label chore · 1 year ago
  • avatar~clover added label lib · 11 months ago
  • avatar~clover added label site · 11 months ago
  • avatar~clovercommented · 11 months ago
    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.